gemini-code-assist[bot] commented on code in PR #19750:
URL: https://github.com/apache/tvm/pull/19750#discussion_r3403585113


##########
tests/python/relax/test_frontend_onnx.py:
##########
@@ -804,6 +804,35 @@ def test_sign_nan_preserve():
     )
 
 
+def test_relu_nan_preserve():
+    relu_node = helper.make_node("Relu", ["x"], ["y"])
+    graph = helper.make_graph(
+        [relu_node],
+        "relu_nan_test",
+        inputs=[helper.make_tensor_value_info("x", TensorProto.FLOAT, [5])],
+        outputs=[helper.make_tensor_value_info("y", TensorProto.FLOAT, [5])],
+    )
+    model = helper.make_model(graph, producer_name="relu_nan_test")
+    model.ir_version = 8
+    for opset_import in model.opset_import:
+        if opset_import.domain in ["", "ai.onnx"]:
+            opset_import.version = 18
+            break
+    x = np.array([np.nan, 9.0, -9.0, 0.0, np.nan], dtype=np.float32)
+
+    ort_out = onnxruntime.InferenceSession(
+        model.SerializeToString(), providers=["CPUExecutionProvider"]
+    ).run([], {"x": x})[0]
+
+    tvm_out = run_in_tvm(model, inputs={"x": x}, opset=18)
+    out_np = (tvm_out[0] if isinstance(tvm_out, list | tuple) else 
tvm_out).numpy()

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using `list | tuple` with `isinstance` (PEP 604 union types in `isinstance`) 
was introduced in Python 3.10. Since TVM supports Python versions prior to 3.10 
(such as 3.8 and 3.9), this will raise a `TypeError` at runtime on those 
versions. Please use a tuple of types `(list, tuple)` instead to maintain 
backward compatibility.
   
   ```suggestion
       out_np = (tvm_out[0] if isinstance(tvm_out, (list, tuple)) else 
tvm_out).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: [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