You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Lunderberg (via GitHub)" <gi...@apache.org> on 2023/12/06 21:22:38 UTC

[PR] [Unity] De-duplicate calls to TensorStructInfo constructor [tvm]

Lunderberg opened a new pull request, #16209:
URL: https://github.com/apache/tvm/pull/16209

   Prior to this commit, the `TensorStructInfo` constructor took as input a `VDevice`, with a default value of `VDevice()`, and then assigned it to a member of type `Optional<VDevice>`.  This commit changes the constructor signature to match the member type, which will remove unnecessary type conversions when copying a `TensorStructInfo`.


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Unity] De-duplicate calls to TensorStructInfo constructor [tvm]

Posted by "yongwww (via GitHub)" <gi...@apache.org>.
yongwww merged PR #16209:
URL: https://github.com/apache/tvm/pull/16209


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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Unity] De-duplicate calls to TensorStructInfo constructor [tvm]

Posted by "Lunderberg (via GitHub)" <gi...@apache.org>.
Lunderberg commented on code in PR #16209:
URL: https://github.com/apache/tvm/pull/16209#discussion_r1418934749


##########
src/relax/op/tensor/manipulate.cc:
##########
@@ -967,36 +894,22 @@ StructInfo InferStructInfoSplit(const Call& call, const BlockBuilder& ctx) {
     }
     // Fall back to unknown shape when the input tensor doesn't have ShapeExpr as shape.
     if (data_shape == nullptr) {
-      if (data_sinfo->vdevice.defined()) {
-        return TupleStructInfo(Array<StructInfo>(
-            n_section,
-            TensorStructInfo(data_sinfo->dtype, data_sinfo->ndim, data_sinfo->vdevice.value())));
-      }
-      return TupleStructInfo(
-          Array<StructInfo>(n_section, TensorStructInfo(data_sinfo->dtype, data_sinfo->ndim)));
+      return TupleStructInfo(Array<StructInfo>(
+          n_section, TensorStructInfo(data_sinfo->dtype, data_sinfo->ndim, data_sinfo->vdevice)));
     }
     ICHECK_NE(axis, -1);
     PrimExpr split_len = ceildiv(data_shape->values[axis], n_section);
 
     // Construct struct info for tensors except the last one.
     Array<PrimExpr> shape = data_shape->values;
     shape.Set(axis, split_len);
-    if (data_sinfo->vdevice.defined()) {
-      std::vector<StructInfo> output_sinfo(
-          n_section - 1,
-          TensorStructInfo(ShapeExpr(shape), data_sinfo->dtype, data_sinfo->vdevice.value()));
-    }
-    std::vector<StructInfo> output_sinfo(n_section - 1,
-                                         TensorStructInfo(ShapeExpr(shape), data_sinfo->dtype));
+    std::vector<StructInfo> output_sinfo(

Review Comment:
   This is the only location in the PR that should make a change on the observed behavior.  Prior to this commit, whenever `data_sinfo->vdevice` is defined, the body of the conditional constructed an instance of `std::vector<StructInfo>`, which is then destructed without being used at the end of the conditional.
   
   With this commit, the `data_sinfo->device` is propagated to the output, which I believe to be the intent of the original.



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

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org