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 2021/04/29 17:45:37 UTC

[GitHub] [tvm] altanh commented on a change in pull request #7945: [RELAY] Turn reshape into nop in graph executor backend.

altanh commented on a change in pull request #7945:
URL: https://github.com/apache/tvm/pull/7945#discussion_r623262746



##########
File path: src/relay/transforms/fuse_ops.cc
##########
@@ -949,14 +949,29 @@ class FuseMutator : private MixedModeMutator {
 
   Expr MakeNewFunction(GraphPartitioner::Group* group, Type ret_type, Expr body) {
     // If the function has no call, it is not a primitive function.
-    struct HasCallVisitor : ExprVisitor {
+    struct PropertyVisitor : ExprVisitor {
       bool has_call = false;
-      void VisitExpr_(const CallNode* op) final { has_call = true; }
+      bool reshape_only = true;
+      void VisitExpr_(const CallNode* op) final {
+        static const Op& reshape_op_ = Op::Get("reshape");

Review comment:
       similar to my previous comment, we'd at least want to include a check for `reverse_reshape` op, but I think we should generalize and make it less ad hoc if possible

##########
File path: include/tvm/relay/function.h
##########
@@ -144,6 +144,9 @@ constexpr const char* kComposite = "Composite";
 constexpr const char* kInline = "Inline";
 /*! \brief Indicate the function was created by the Pattern Partitioning Pass. */
 constexpr const char* kPartitionedFromPattern = "PartitionedFromPattern";
+
+/*! \brief Mark the function as only composed of reshape operations. */
+constexpr const char* kReshapeOnly = "relay.reshape_only";

Review comment:
       are there other ops that could benefit? for example `squeeze`, `expand_dims`, etc.? I feel like this should more generally be like `relay.alias_only` (although alias might be too general since you could "alias" a subset of an input by slicing)




-- 
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