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

   ### Expected behavior
   TVM should give the same inference results with ONNX runtime.
   
   ### Actual behavior
   
![image](https://github.com/apache/tvm/assets/29506758/9f1ccea5-7bc9-44fc-b247-a705b5f2e664)
   
   
   ### Steps to reproduce:
   Add a new test case in the official unit test: 
`tvm/tests/python/frontend/onnx/test_forward.py`.
   Execute the test cases, the result is shown above.
   ```
   @tvm.testing.parametrize_targets
   def test_onehot2(target='llvm', dev=tvm.cpu(0)):
       """test_onehot"""
       indices_shape = [10]
       indices_array = np.random.randint(low=0, high=5, size=indices_shape, 
dtype="int32")
       #indices_array = np.asarray([0, 1, 2,3,4,5,6,7,8,9], dtype='int32')
       print(indices_array)
       depth = 6
       values = np.asarray([0, 1]).astype("int32")
       out_np = np.eye(depth)[indices_array.reshape(-1)]
   
       onehot_node = helper.make_node("OneHot", ["indices", "depth", "values"], 
["out"], axis=0)
   
       graph = helper.make_graph(
           [onehot_node],
           "onehot_test",
           inputs=[
               helper.make_tensor_value_info("indices", TensorProto.INT32, 
indices_shape),
               helper.make_tensor_value_info("depth", TensorProto.INT32, [1]),
               helper.make_tensor_value_info("values", TensorProto.INT32, 
values.shape),
           ],
           outputs=[helper.make_tensor_value_info("out", TensorProto.INT32, 
out_np.shape)],
       )
   
       model = helper.make_model(graph, producer_name="onehot_test")
   
       tvm_out = get_tvm_output_with_vm(
           model, [indices_array, np.array([depth]).astype("int32"), values], 
target, dev
       )
       print(out_np)
       print(tvm_out)
       tvm.testing.assert_allclose(out_np, tvm_out, rtol=1e-5, atol=1e-5)
   ```
   
   ### Description
   This bug can be triggered when the axis is not -1.
   By checking the source code in Relay, It lacks the logic to reshape the 
final output shape, leading to the wrong output shape.
   
   


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

Reply via email to