[Mlir-commits] [mlir] [MLIR] [Python] The generated op definitions now use typed parameters (PR #188635)
Sergei Lebedev
llvmlistbot at llvm.org
Thu Mar 26 10:57:45 PDT 2026
================
@@ -475,11 +482,31 @@ class Sliceable {
nanobind::handle elemTyName = nanobind::detail::nb_type_name(elemTyInfo);
std::string sig = std::string("class ") + Derived::pyClassName +
"(collections.abc.Sequence[" +
- nanobind::cast<std::string>(elemTyName) + "])";
- auto clazz = nanobind::class_<Derived>(m, Derived::pyClassName,
- nanobind::type_slots(sequenceSlots),
- nanobind::sig(sig.c_str()))
- .def("__add__", &Sliceable::dunderAdd);
+ nanobind::cast<std::string>(elemTyName) + "]";
+ if constexpr (!Derived::typeParams.empty()) {
+ sig += ", typing.Generic[";
+ for (size_t i = 0; i < Derived::typeParams.size(); ++i) {
+ if (i > 0)
+ sig += ", ";
+ const char *tp = Derived::typeParams[i];
+ if (!nanobind::hasattr(m, tp))
+ m.attr(tp) = nanobind::type_var(tp);
+ sig += tp;
----------------
superbobry wrote:
Done.
https://github.com/llvm/llvm-project/pull/188635
More information about the Mlir-commits
mailing list