gemini-code-assist[bot] commented on code in PR #19849:
URL: https://github.com/apache/tvm/pull/19849#discussion_r3446074318
##########
src/relax/transform/fold_constant.cc:
##########
@@ -394,7 +394,7 @@ class ConstantFolder : public ExprMutator {
is_known &= (val.dtype() == DataType::Int(64));
}
if (is_known) {
- const auto func =
tvm::ffi::Function::GetGlobalRequired("relax.run.shape_to_tensor");
+ const auto func =
tvm::ffi::Function::GetGlobalRequired("vm.builtin.shape_to_tensor");
runtime::Tensor vals = func(arr).cast<runtime::Tensor>();
Review Comment:

The `vm.builtin.shape_to_tensor` function expects a `ffi::Shape` (which is
`ShapeTuple`) as its argument, but `arr` is of type `ffi::Array<int64_t>`.
Passing `arr` directly will cause a runtime type mismatch error during constant
folding. We should explicitly construct a `ffi::Shape` from `arr`'s elements.
```c
const auto func =
tvm::ffi::Function::GetGlobalRequired(\"vm.builtin.shape_to_tensor\");\n
runtime::Tensor vals = func(ffi::Shape(arr.begin(),
arr.end())).cast<runtime::Tensor>();
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]