mbrookhart commented on a change in pull request #7125:
URL: https://github.com/apache/tvm/pull/7125#discussion_r551422829



##########
File path: include/tvm/topi/transform.h
##########
@@ -1386,6 +1386,88 @@ inline Array<Tensor> meshgrid(const Array<Tensor>& 
inputs, const std::string& in
   return result;
 }
 
+/*!
+ * \brief Compute new sparse indices and return them after the sparse_reshape 
operation
+ *
+ * \param sparse_indices Indices where values of the dense tensor exist
+ * \param prev_shape Old Shape of the sparse tensor corresponding to 
sparse_indices
+ * \param new_shape Desired Shape of the sparse tensor which will correspond 
to output
+ * \param name The name of the operation
+ * \param tag The tag to mark the operation
+ *
+ * \return A Tensor whose op member is the sparse_reshape operation
+ */
+inline Array<Tensor> SparseReshape(const Tensor& sparse_indices, const Tensor& 
prev_shape,
+                                   const Tensor& new_shape,
+                                   const std::string name = "T_sparse_reshape",
+                                   std::string tag = kInjective) {
+  Array<Tensor> result;
+  Array<PrimExpr> new_sparse_indices_shape{sparse_indices->shape[0], 
new_shape->shape[0]};
+
+  int new_shape_size = GetConstInt(new_shape->shape[0]);
+  int prev_shape_size = GetConstInt(prev_shape->shape[0]);

Review comment:
       My main complaint is that this will fail with dynamic input shapes. From 
what I understand, you expect multiple chained dynamically-shaped sparse ops in 
the model you're trying to target, so I'm hesitant to merge this because I'm 
under the impression that this will not solve the larger problem you're trying 
to solve. 
   
   I'd really like to see you either test the model in a branch containing all 
three of your PRs, or write a unit test with a representative subgraph.




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