icemelon9 commented on a change in pull request #5429:
URL: https://github.com/apache/incubator-tvm/pull/5429#discussion_r418644047



##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -504,17 +548,38 @@ bool ReshapeRel(const Array<Type>& types,
     return false;
   }
 
-  const auto* param = attrs.as<ReshapeAttrs>();
+  Array<IndexExpr> oshape;
   Array<IndexExpr> data_shape;
   Array<Integer> newshape;
-  if (param->reverse) {
-    data_shape.assign(data->shape.rbegin(), data->shape.rend());
-    newshape.assign(param->newshape.rbegin(), param->newshape.rend());
+  const ConstantNode *attr_newshape;
+
+  if ((attr_newshape = param->newshape.as<ConstantNode>())) {
+    Array<Integer> temp;
+
+    CHECK_EQ(attr_newshape->data->ndim, 1);
+    for (int i = 0; i < attr_newshape->data->shape[0]; i++) {
+      temp.push_back(Integer(static_cast<int>(ToScalar(attr_newshape->data, 
i))));
+    }
+
+    if (param->reverse) {
+      data_shape.assign(data->shape.rbegin(), data->shape.rend());
+      newshape.assign(temp.rbegin(), temp.rend());
+    } else {
+      data_shape = data->shape;
+      newshape = temp;
+    }
   } else {
-    data_shape = data->shape;
-    newshape = param->newshape;
+    const auto* newshape = types[1].as<TensorTypeNode>();
+
+    // Doesn't support dynamic output rank
+    for (int i = 0; i < newshape->shape[0].as<IntImmNode>()->value; i++) {

Review comment:
       This could be incorrect if we have special values like -2, -3, -4.




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