Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROCM] Fixes compiling on ROCM 5 and accuracy on dense op #13847

Merged
merged 1 commit into from
Jan 26, 2023

Conversation

masahi
Copy link
Member

@masahi masahi commented Jan 26, 2023

Fixes #13666

  • Some bitcode files need to be updated
  • There is a strange, device-dependent accuracy issue when using the default topi dense op schedule on AMDGPU (see the issue above). I confirmed that other schedule works fine.

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jan 26, 2023

Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment.

  • No users to tag found in teams: rocm See #10317 for details

Generated by tvm-bot

@masahi masahi changed the title [ROCM] Fixes compiling on ROCM 5 and accuacy on dense op [ROCM] Fixes compiling on ROCM 5 and accuracy on dense op Jan 26, 2023
@mvermeulen
Copy link
Contributor

I checked this with Radeon VII, gfx906 and also works on this platform.

Copy link
Member

@junrushao junrushao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@junrushao junrushao merged commit ec72ac6 into apache:main Jan 26, 2023
@wangzy0327
Copy link

Fixes #13666

  • Some bitcode files need to be updated
  • There is a strange, device-dependent accuracy issue when using the default topi dense op schedule on AMDGPU (see the issue above). I confirmed that other schedule works fine.

I checked this with Radeon VII, gfx906 and also works on this platform.

I test this with gfx908 but not works on the platform.

See details as #13666

@mvermeulen

@wangzy0327
Copy link

@ masahi @mvermeulen I use the commit masahi:rocm-t-fix to build and run code.But I get error as follow.

onnx_rocm.py ```

from pyexpat import model
import onnx
#from tvm.driver import tvmc
import numpy as np
import tvm
import tvm.relay as relay
from tvm.contrib import graph_executor
import tvm.testing
import numpy as np

dtype="float32"
common_prefix_str = "onnx-model/vision/classification/"
tol_paras = [1e-7,1e-6,1e-5,1e-4,1e-3,1e-2]
input_name = "Input3"
input_size = (1,1,28,28)
output_size = (1,10)

import logging
logging.basicConfig(level=logging.ERROR)

import warnings
warnings.filterwarnings('ignore')

def build(target:str,mod:tvm.IRModule, params:dict, input_name:str, input_data:np.ndarray, input:tuple, output: tuple) -> np.ndarray:
tgt = tvm.target.Target(target=target, host="llvm")
with tvm.transform.PassContext(opt_level=3):
lib = relay.build(mod, target=target, params=params)
dev = tvm.device(str(target), 0)
module = graph_executor.GraphModule(lib"default")
module.set_input(input_name, input_data)
module.run()
output_shape = output
tvm_output = module.get_output(0, tvm.nd.empty(output_shape)).numpy()
return tvm_output

def main():
np.random.seed(0)
I_np = np.random.uniform(size = input_size).astype(dtype)
print(I_np[0][0][0][:10])
onnx_model = onnx.load("onnx-model/vision/classification/mnist/model/mnist-7.onnx")
mod,params = relay.frontend.from_onnx(onnx_model,{"Input3":I_np.shape})
rocm_lib_output = build("rocm -libs=miopen",mod = mod,params = params,input_name = input_name,input_data = I_np, input = I_np.shape, output = output_size)
rocm_output = build("rocm",mod = mod,params = params,input_name = input_name,input_data = I_np, input = I_np.shape, output = output_size)
opencl_output = build("opencl",mod = mod,params = params,input_name = input_name,input_data = I_np, input = I_np.shape, output = output_size)
print(rocm_output[0][:10])
print(rocm_lib_output[0][:10])
print(opencl_output[0][:10])

main()

</details>

![image](https://user-images.githubusercontent.com/22990858/217220410-91c890d8-b74e-4189-98d6-d783a00fc4cd.png)

fzi-peccia pushed a commit to fzi-peccia/tvm that referenced this pull request Mar 27, 2023
Fixes apache#13666

* Some bitcode files need to be updated
* There is a strange, device-dependent accuracy issue when using the default topi `dense` op schedule on AMDGPU (see the issue above). I confirmed that other schedule works fine.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] rocm platform result are not correct
5 participants