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



##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -47,6 +47,66 @@ namespace tvm {
 namespace relay {
 using tir::IntImmNode;
 
+int64_t* ToVector(const runtime::NDArray& array) {
+  size_t len = array.Shape().front();
+  int64_t* rel_vec = new int64_t[len];

Review comment:
       Also consider move this function and [similar 
one](https://github.com/apache/incubator-tvm/blob/master/src/relay/op/tensor/transform.cc#L450)
 to some util.h so that others can reuse.

##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -944,7 +1005,21 @@ bool FullRel(const Array<Type>& types, int num_inputs, 
const Attrs& attrs,
   CHECK_EQ(fill_value->shape.size(), 0)
       << "Fill value should be a scalar but has dimension " << 
fill_value->shape.size() << ".";
 
-  reporter->Assign(types[1], TensorType(param->shape, out_dtype));
+  const IntImmNode* shape_shape = fill_shape->shape[0].as<IntImmNode>();
+  CHECK(shape_shape) << "Parameter shape must have static shape";
+
+  std::vector<IndexExpr> oshape;
+  if (param->shape) {
+    const Array<Integer>& cshape_array = param->shape.value();
+    for (size_t i = 0; i < cshape_array.size(); ++i) {
+      oshape.push_back(cshape_array[i]);
+    }

Review comment:
       I think you can merge line 1013-1016 to `ToVector` function since all 
the use cases need `Array`.

##########
File path: src/relay/op/tensor/transform.cc
##########
@@ -47,6 +47,66 @@ namespace tvm {
 namespace relay {
 using tir::IntImmNode;
 
+int64_t* ToVector(const runtime::NDArray& array) {
+  size_t len = array.Shape().front();
+  int64_t* rel_vec = new int64_t[len];

Review comment:
       Please don't use raw pointer. it will cause memory leak.

##########
File path: topi/python/topi/sort.py
##########
@@ -133,7 +133,10 @@ def topk(data, k=1, axis=-1, ret_type="both", 
is_ascend=False, dtype="int64"):
     assert ret_type in ["both", "values", "indices"]
     data_buf = tvm.tir.decl_buffer(data.shape, data.dtype, "data_buf", 
data_alignment=8)
     out_shape = list(get_const_tuple(data.shape))
-    if k >= 1:
+    kvar = tvm.te.var("k")

Review comment:
       ```suggestion
       kvar = tvm.te.size_var("k")
   ```




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