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

   ### Expected behavior
   
   TVM Relax should not crash the Python process when executing an imported 
ONNX `Div` model with integer inputs.
   
   For integer division by zero, TVM should either handle the case safely or 
report a controlled runtime error instead of terminating the process with 
`SIGFPE`.
   
   ### Actual behavior
   
   The model compiles successfully, but calling the Relax VM crashes the 
subprocess with exit code `-8`:
   
   ```
   stdout: calling vm[main]
   
   exit  : -8
   ```
   
   This happens when the divisor tensor contains zero values for an `INT32` 
ONNX `Div` model.
   
   ### Environment
   
   TVM: 0.14 environment / Relax ONNX frontend
   Python: 3.11
   Target: llvm
   OS: Linux
   
   ### Steps to reproduce
   
   ```
   import subprocess
   import sys
   import textwrap
   
   
   SCRIPT = textwrap.dedent("""\
       import numpy as np
       import onnx
       from onnx import helper, TensorProto
       import tvm
       from tvm import relax
       from tvm.relax.frontend.onnx import from_onnx
   
       node = helper.make_node("Div", ["a", "b"], ["y"])
   
       graph = helper.make_graph(
           [node],
           "g",
           [
               helper.make_tensor_value_info("a", TensorProto.INT32, [4]),
               helper.make_tensor_value_info("b", TensorProto.INT32, [4]),
           ],
           [helper.make_tensor_value_info("y", TensorProto.INT32, [4])],
       )
   
       model = helper.make_model(
           graph,
           opset_imports=[helper.make_opsetid("", 18)],
       )
       model.ir_version = 9
   
       mod = from_onnx(model, keep_params_in_input=False)
   
       with tvm.transform.PassContext(opt_level=3):
           ex = tvm.compile(mod, target=tvm.target.Target("llvm"))
   
       vm = relax.VirtualMachine(ex, tvm.cpu())
   
       a = np.array([42, 99, -50, 7], dtype=np.int32)
       b = np.array([3, 0, 0, 1], dtype=np.int32)
   
       print("calling vm[main]", flush=True)
   
       out = vm["main"](
           tvm.runtime.tensor(a, tvm.cpu()),
           tvm.runtime.tensor(b, tvm.cpu()),
       )
   
       out = out[0] if isinstance(out, (list, tuple)) else out
       print("returned:", out.numpy().tolist())
   """)
   
   
   proc = subprocess.run(
       [sys.executable, "-c", SCRIPT],
       capture_output=True,
       text=True,
       timeout=60,
   )
   
   print("stdout:", proc.stdout)
   print("stderr:", proc.stderr)
   print("exit  :", proc.returncode)
   ```
   
   ### 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