You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "cbalint13 (via GitHub)" <gi...@apache.org> on 2025/08/14 10:27:14 UTC

[PR] [Fix][ONNX] No precision widening for numpy binary operations [tvm]

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

   This PR enforce ONNX constraint compliance for binary operations.
   
   ---
   
   #### Changes
   
   * Overides the behaviour of numpy precision widening, e.g. ```np.div(int64,in64)->float64```
   * This **now complies** with the [onnx.Div](https://onnx.ai/onnx/operators/onnx__Div.html) output constraint: ```C: Result, has same element type as two inputs```.
   * Use an more appropriate public helper from API for the numpy type conversion (now it works with onnx 0.20 too).
   
   ---
   
   #### Failure example
   
      After shape sampling and division in the graph (excerpt from a custom onnx11n model) ```np.div(5,2)``` results in a ```float64``` (as per numpy behaviour) and then the input parameter of ```Slice``` fails upon its ```int64``` constraint.
   
     <img width="381" height="620" alt="onnx-div-widening-issue" src="https://github.com/user-attachments/assets/60fbd252-81f9-4ed7-842d-a2040f5923bd" />
   
     ```
     tvm.error.InternalError: Check failed: (is_base_of_tuple_of_int64(sinfo)) is false: 
     Operator Op(relax.strided_slice) requires the end argument to be a tuple of int64 PrimValues.  
     However, in expression {...}, the end argument (R.prim_value(T.float64(2.5)),) has struct info
     R.Tuple(R.Prim(value=T.float64(2.5)))
   
     ```
   
   
   


-- 
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] [Fix][ONNX] No precision widening for numpy binary operations [tvm]

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


-- 
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] [Fix][ONNX] No precision widening for numpy binary operations [tvm]

Posted by "cbalint13 (via GitHub)" <gi...@apache.org>.
cbalint13 commented on PR #18207:
URL: https://github.com/apache/tvm/pull/18207#issuecomment-3188922420

   Cc @Hzfengsy 


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