ALinrunrun opened a new issue, #19561:
URL: https://github.com/apache/tvm/issues/19561

   ### Expected behavior
   
   TVM Relax should execute ONNX `Asinh` consistently with ONNX Runtime for 
large finite float32 inputs.
   
   For large finite values, `asinh(x)` should remain finite and approximately 
grow like `log(2x)`. Negative inputs should produce negative outputs.
   
   ### Actual behavior
   
   TVM Relax returns `inf` for all elements, while ONNX Runtime returns finite 
values:
   
   ```
   input: [ 3.e+22  5.e+25 -8.e+23]
   ORT  : [ 52.44863   59.86721  -55.732044]
   TVM  : [inf inf inf]
   ```
   
   The discrepancy appears when importing an ONNX Asinh model through the Relax 
ONNX frontend and compiling it for the llvm target.
   
   ### Environment
   
   TVM: 0.14 environment / Relax ONNX frontend
   ONNX Runtime: 1.23
   Python: 3.11
   Target: llvm
   OS: Linux
   
   ### Steps to reproduce
   
   ```
   import warnings
   
   warnings.filterwarnings("ignore")
   
   import numpy as np
   import onnxruntime as ort
   import tvm
   from onnx import TensorProto, helper
   from tvm import relax
   from tvm.relax.frontend.onnx import from_onnx
   
   
   node = helper.make_node("Asinh", ["x"], ["y"])
   
   graph = helper.make_graph(
       [node],
       "g",
       [helper.make_tensor_value_info("x", TensorProto.FLOAT, [3])],
       [helper.make_tensor_value_info("y", TensorProto.FLOAT, [3])],
   )
   
   model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 20)])
   model.ir_version = 9
   
   x = np.array([3e22, 5e25, -8e23], dtype=np.float32)
   
   ort_out = ort.InferenceSession(
       model.SerializeToString(),
       providers=["CPUExecutionProvider"],
   ).run(None, {"x": x})[0]
   
   mod = from_onnx(model)
   
   with tvm.transform.PassContext(opt_level=3):
       ex = tvm.compile(mod, target=tvm.target.Target("llvm"))
   
   vm = relax.VirtualMachine(ex, tvm.cpu())
   
   out = vm["main"](tvm.runtime.tensor(x, tvm.cpu()))
   tvm_out = (out[0] if isinstance(out, (list, tuple)) else out).numpy()
   
   print("input:", x)
   print("ORT  :", ort_out)
   print("TVM  :", tvm_out)
   ```
   
   ### Triage
   
   * needs-triage
   


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

Reply via email to