You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2019/12/27 19:30:11 UTC
[GitHub] [incubator-tvm] comaniac commented on a change in pull request
#4594: [relay][refactor] Refactor GetOp to IsOp utility
comaniac commented on a change in pull request #4594: [relay][refactor] Refactor GetOp to IsOp utility
URL: https://github.com/apache/incubator-tvm/pull/4594#discussion_r361731247
##########
File path: include/tvm/relay/op.h
##########
@@ -610,6 +610,19 @@ inline bool IsPrimitiveOp(const Expr& expr) {
return op != nullptr && op->IsPrimitiveOp();
}
+/*!
+ * \brief Check if an op is the one with the provided name.
+ *
+ * \param ref The op to be checked.
+ * \param name The given operator name.
+ *
+ * \return True if the op is the same with the given name. Otherwise, false.
+ */
+inline bool IsOp(const NodeRef& ref, const std::string& name) {
+ CHECK(ref.defined());
+ return ref->IsInstance<OpNode>() && Downcast<Op>(ref) == Op::Get(name);
Review comment:
We may need to add a checker to make sure `Op::Get()` retuerns a valid op in case the given op name string has a typo. The checker can also help debugging; otherwise it's hard to find the problems if `IsOp` returns false due to typos.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services