Menooker commented on a change in pull request #5357:
URL: https://github.com/apache/incubator-tvm/pull/5357#discussion_r415208733



##########
File path: src/relay/transforms/fold_scale_axis.cc
##########
@@ -314,6 +318,42 @@ class ForwardPrep : private ExprVisitor {
   }
 };
 
+static bool IsIntInArray(const Array<Integer>& axis, int v) {
+  for (size_t i = 0; i < axis.size(); i++) {
+    if (axis[i] == v)
+      return true;
+  }
+  return false;
+}
+
+static Expr ReshapeToMatchAxis(Expr scale, const Array<PrimExpr>& shape,
+  const Array<Integer>& axis) {
+  Array<Integer> arr;
+  for (size_t i = 0; i < shape.size(); i++) {
+    if (IsIntInArray(axis, i)) {
+      auto node = shape[i].as<IntImmNode>();
+      if (!node) {
+        // if the shape is not a constant, use normal transform
+        return Expr();

Review comment:
       I have changed `CHECK(scale.defined())` now. It now fallbacks to a 
"optimization failure" rather than a compilation error.
   For ForwardRewrite, if the shape is not constant, the rewriter will return 
`Expr()`.
   For BackwardRewrite, if the shape is not constant, the rewriter will return 
`transformer->NormalCallTransform(call.operator->())`.




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