This is an archive of the discontinued LLVM Phabricator instance.

[mlir][python] Add tests for implicit pybind casts.
AbandonedPublic

Authored by ingomueller-net on Aug 30 2023, 2:37 AM.

Details

Summary

https://reviews.llvm.org/D158974 Implement __<type>__ functions for
bool, float, int, and str for automatic casts in functions bound
by pybind11. This patch tests their behavior more thoroughly. In
particular, this clarifies an open question from the dicussion of above
patch: values for string parameters, unlike for the other types, are
*not* cast implicitly with str(.)

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2023, 2:37 AM
ingomueller-net requested review of this revision.Aug 30 2023, 2:37 AM

Is there still a reason to implement __str__ for StringAttr then? It seems to just add inconsistency, as the implementation on every other attribute gives the asm string.

Do these tests provide value beyond finding out how __str__ and pybind11 interact? If yes, I guess I'll rebase this patch on top of https://reviews.llvm.org/D159255 and land (after approval)...

I think only the positive tests for Attribute conversions are really relevant. And since that's covered by tests in the original change, it seems fine to drop this patch.

ingomueller-net abandoned this revision.Sep 1 2023, 12:38 AM

The only thing that isn't tested that explicitly in the attributes tests is that the automatic conversion done by pybind works as expected. But in a way that's a pybind feature... Abandoning.