diff --git a/imperative/python/megengine/core/autodiff/grad.py b/imperative/python/megengine/core/autodiff/grad.py index 4a6114dc..805e0437 100644 --- a/imperative/python/megengine/core/autodiff/grad.py +++ b/imperative/python/megengine/core/autodiff/grad.py @@ -123,6 +123,11 @@ class Function(ops.PyOpBase): This method should return a tuple of Tensor or a single Tensor representing the output of the function. + + .. note:: + + positional arguments should all be Tensor + """ raise NotImplementedError diff --git a/imperative/src/impl/op_trait.cpp b/imperative/src/impl/op_trait.cpp index 640583a6..59b3241d 100644 --- a/imperative/src/impl/op_trait.cpp +++ b/imperative/src/impl/op_trait.cpp @@ -98,6 +98,12 @@ OpTraitRegistry& OpTraitRegistry::fallback() { if (!trait->decide_dispatch_mode) { trait->decide_dispatch_mode = fallback_decide_dispatch_mode; } + if (!trait->make_name) { + static auto make_name = [](const OpDef& def) -> std::string { + return def.trait()->name; + }; + trait->make_name = make_name; + } return *this; } diff --git a/imperative/src/impl/ops/utility.cpp b/imperative/src/impl/ops/utility.cpp index 14654134..f40eef42 100644 --- a/imperative/src/impl/ops/utility.cpp +++ b/imperative/src/impl/ops/utility.cpp @@ -18,6 +18,7 @@ namespace mgb::imperative { MGB_DYN_TYPE_OBJ_FINAL_IMPL(GenericPyOp); +OP_TRAIT_REG(GenericPyOp, GenericPyOp).fallback(); namespace { namespace fastpathcopy { auto apply_on_var_node(