Refactor python bindings to enable subclassing values and overloading operators on both python and cpp side. The test shows one use-case (tensor wrapper indexing maps to tensor.extract).
There are two ways to make this work (both on display in the sequence of commits);
- Move PyConcreteValue to a public header(https://reviews.llvm.org/D147758?vs=on&id=511599#toc)
- (Current) Add mlir_value_subclass but also add a python side constructor to py::class_<PyValue>
I can't comment on the relative merits/tradeoffs; first one "breaks symmetry" with mlir_type_subclass and mlir_attribute_subclass, while second potentially does a bad thing in adding a constructor to py::class_<PyValue> where I believe the intent is to not have one.
Note in the diff demonstrating the first approach there are some stray PYBIND11_EXPORTs (i.e., they are not necessary).
I'll be honest I'm not 100% sure why this works (cf the Value(t) in the test) since there is no single argument constructor for PyValue. But it does indeed pass on in all my envs.