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

[GitHub] [incubator-tvm] kongroo opened a new pull request #6349: [CODEGEN][CUDA]: fix cuda half math function is undefined: herf

kongroo opened a new pull request #6349:
URL: https://github.com/apache/incubator-tvm/pull/6349


   I got an "identifier herf undefined" error when converting a model into TVM, which can be reproduced by the following code
   ```
   import torch
   import numpy as np
   import tvm
   from tvm import relay
   
   class ErfTest(torch.nn.Module):
       def forward(self, data):
           return torch.erf(data)
   
   def run(data):
       # convert pytorch to tvm
       traced = torch.jit.trace(ErfTest(), torch.from_numpy(data).cuda())
       mod, params = relay.frontend.from_pytorch(traced, [('data', data.shape)])
   
       # compile
       with tvm.transform.PassContext(opt_level=3):
           relay_graph, relay_lib, relay_params = tvm.relay.build(mod, target='cuda', params=params)
           relay_model = tvm.contrib.graph_runtime.create(relay_graph, relay_lib, tvm.context('gpu', 0))
   
       # run
       relay_model.set_input('data', data)
       relay_model.run()
       return relay_model.get_output(0)
   
   data = np.random.rand(3, 4).astype(np.float32)
   print(torch.erf(torch.Tensor(data)))
   print(run(data))
   print(run(data.astype(np.float16)))
   ```
   ![image](https://user-images.githubusercontent.com/16698151/91425664-04197a00-e88e-11ea-8212-5e08ec9b4650.png)
   
   I fixed this in the same way as #6225 and the results seem ok
   
   <img src="https://user-images.githubusercontent.com/16698151/91427276-3deb8000-e890-11ea-8fa0-2fb0c3585cae.png" width="300">
   
   cc @vinx13 Could you help to review this?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] kongroo commented on pull request #6349: [CODEGEN][CUDA]: fix cuda half math function is undefined: herf

Posted by GitBox <gi...@apache.org>.
kongroo commented on pull request #6349:
URL: https://github.com/apache/incubator-tvm/pull/6349#issuecomment-682406774


   > Could you add test cases for half math of erf to verify the accuracy?
   
   I have added a test case for half erf, but ci failed. It seems that this condition `#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ >= 530)` is not met in the ci environment, and herf is still undefined. Should I just remove the test case?


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] vinx13 commented on pull request #6349: [CODEGEN][CUDA]: fix cuda half math function is undefined: herf

Posted by GitBox <gi...@apache.org>.
vinx13 commented on pull request #6349:
URL: https://github.com/apache/incubator-tvm/pull/6349#issuecomment-686851043


   You can add a check of cuda compute capability and skip the test if not supported 


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tqchen commented on pull request #6349: [CODEGEN][CUDA]: fix cuda half math function is undefined: herf

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #6349:
URL: https://github.com/apache/incubator-tvm/pull/6349#issuecomment-693017408


   @kongroo @vinx13 please followup 


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] kongroo closed pull request #6349: [CODEGEN][CUDA]: fix cuda half math function is undefined: herf

Posted by GitBox <gi...@apache.org>.
kongroo closed pull request #6349:
URL: https://github.com/apache/incubator-tvm/pull/6349


   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org