echuraev commented on code in PR #15683:
URL: https://github.com/apache/tvm/pull/15683#discussion_r1318118522


##########
python/tvm/relay/frontend/pytorch.py:
##########
@@ -4424,7 +4424,10 @@ def _create_typed_const(data, dtype):
     dtype should be a TVM dtype"""
 
     if dtype == "float64":
-        typed_data = _expr.const(np.float64(data), dtype=dtype)
+        if len(data) == 1:
+            typed_data = _expr.const(np.array([np.float64(data)]), dtype=dtype)
+        else:
+            typed_data = _expr.const(np.float64(data), dtype=dtype)

Review Comment:
   I read your updates in the issue, thank you for detailed description. Here 
it looks like a workaround above numpy bug. I think that the best way to fix 
this issue is to create an issue or a PR in the numpy repo with fix.
   
   Currently, this implementation won't work after fixing the bug in numpy. My 
suggestion is to create an issue or PR with fix to numpy repository and at the 
same time change the current implementation in the following way:
   ```suggestion
           typed_data = np.float64(data)
           if np.isscalar(typed_data):
               typed_data = _expr.const(np.array([typed_data]), dtype=dtype)
           else:
               typed_data = _expr.const(typed_data, dtype=dtype)
   ```
   This code should work also after fixing the bug in Numpy.



-- 
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-unsubscr...@tvm.apache.org

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

Reply via email to