mseth10 commented on a change in pull request #18690:
URL: https://github.com/apache/incubator-mxnet/pull/18690#discussion_r459798576



##########
File path: src/operator/subgraph/static_shape_subgraph_property.cc
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include "./common.h"
+#include "./subgraph_property.h"
+#include "../../imperative/cached_op.h"
+
+namespace mxnet {
+namespace op {
+
+/*
+ * This selects nodes for a subgraph that only contains static shape operators
+ * and it visits nodes via both input and output links.
+ */
+class StaticShapeOpSelector: public SubgraphSelector {
+ public:
+  virtual bool Select(const nnvm::Node &seed_node) {
+    const auto& infershape = 
nnvm::Op::GetAttr<mxnet::FInferShape>("FInferShape");
+    return !seed_node.is_variable() && infershape.count(seed_node.op());
+  }
+
+  virtual bool SelectInput(const nnvm::Node &cur_node, const nnvm::Node 
&input_node) {
+    const auto& infershape = 
nnvm::Op::GetAttr<mxnet::FInferShape>("FInferShape");
+    return !input_node.is_variable() && infershape.count(input_node.op());
+  }
+
+  virtual bool SelectOutput(const nnvm::Node &cur_node, const nnvm::Node 
&output_node) {
+    const auto& infershape = 
nnvm::Op::GetAttr<mxnet::FInferShape>("FInferShape");
+    return !output_node.is_variable() && infershape.count(output_node.op());
+  }

Review comment:
       right, there is no advantage of having a single node subgraph, we can 
reject such subgraphs in the subgraph property's `CreateSubgraphNode` function.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to