You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by akamiri via Apache TVM Discuss <no...@discuss.tvm.ai> on 2023/08/11 17:50:16 UTC

[Apache TVM Discuss] [Questions] Inquiry About Obtaining PTX Assembly Code from TVM


Hello,

I'm currently studying how neural network models are executed on GPUs.  As part of my studies, I am particularly interested in obtaining the PTX  assembly code for network models after they have been compiled using TVM.

I have been exploring the capabilities of TVM and have successfully compiled neural network models to run on GPUs. 

I'd like to know how to access the PTX assembly code generated after compiling network models using TVM. Could you please guide me on how to obtain this PTX code?





---
[Visit Topic](https://discuss.tvm.apache.org/t/inquiry-about-obtaining-ptx-assembly-code-from-tvm/15510/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/e9f08e046752f58465ddd0dc30a4542e5c899b06a30c87a3f7fa9a9ed4aa956b).

[Apache TVM Discuss] [Questions] Inquiry About Obtaining PTX Assembly Code from TVM

Posted by Siyuan Feng via Apache TVM Discuss <no...@discuss.tvm.ai>.

Another way is to override `tvm_callback_cuda_compile`

```python
def my_cuda_compile(code, target):
     # Code to print or write to file
     return nvcc.compile_cuda(code)

tvm.register_func("tvm_callback_cuda_compile", my_cuda_compile, override=True)
```





---
[Visit Topic](https://discuss.tvm.apache.org/t/inquiry-about-obtaining-ptx-assembly-code-from-tvm/15510/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/b93980fc41275f8ec310635a5ba76db88c21a2a710e2677c624011e25c31654a).

[Apache TVM Discuss] [Questions] Inquiry About Obtaining PTX Assembly Code from TVM

Posted by Lei Wang via Apache TVM Discuss <no...@discuss.tvm.ai>.

As I know about tvm, for single op, tvm can compile high level ir to cuda c source code, and then use the nvcc to compile the source into an executable. To extract the PTX code, you can retrieve the source code and use appropriate tools to compile it into PTX.

```python
cuda_mod = tvm.build(sch.mod, target="cuda")
c_source_code = cuda_mod.imported_modules[0].get_source()

# Save the CUDA C source code to a file  
with open("cuda_source_code.cu", "w") as output_file:  
    output_file.write(c_source_code)  
# nvcc -ptx -o output.ptx cuda_source_code.cu  
```

Btw, I think the simplest way to obtain the ptx code is to use Nvidia Nsight Compute to profile a TVM CUDA runtime. You can get the ptx code in the source window.

Regarding the network, I don't see any built-in pass that directly generates a PTX source file.





---
[Visit Topic](https://discuss.tvm.apache.org/t/inquiry-about-obtaining-ptx-assembly-code-from-tvm/15510/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/dd1abab4f9e9b830a8c250e2d2022376ac48278d0a63dffc30143bdeedb9aaee).

[Apache TVM Discuss] [Questions] Inquiry About Obtaining PTX Assembly Code from TVM

Posted by tsu-bin via Apache TVM Discuss <no...@discuss.tvm.ai>.

hi all,

Is that LLVM NVPTX backend is not supported any more, or it's not an optimal codegen path working together with tir and metaschedule compared to cuda-c?





---
[Visit Topic](https://discuss.tvm.apache.org/t/inquiry-about-obtaining-ptx-assembly-code-from-tvm/15510/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/4613510609cc5a0ea5904e9f47267151cfc64361f5aea851e8358d3500afcabf).