diff --git a/imperative/python/megengine/core/autodiff/grad.py b/imperative/python/megengine/core/autodiff/grad.py index 4a6114dcf7e6187f241aba12ffd5c4038aab2c6f..805e04370a13b565be7a6aa6ea596f0d85faa73a 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 640583a671ece68d07e6da9e6d053a1dc8d956c6..59b3241daf597a8967c4caca7e6ec69ff5f70a07 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 14654134bc96f88dd9be6bc22316f132e9e96c36..f40eef420b3efe2f8c845230292012de39d6322b 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(