Hello everyone, I've worked a lot with LLVM but new to TVM. I would like to 
implement my own tvm backend to codegen custom llvm-IR. 

However, it seems that the infrastructure API has vastly changed in the latest 
release version(0.20.0). I'm looking for an equivalent api of the `get_source` 
method in relay to obtain the generated llvm-ir in text form, namely:
```python
with tvm.transform.PassContext(opt_level=3):
    lib=tvm.build(mod, target=target)
print(lib.get_source())
```

I've been struggling to find the correct api. I've managed to generate 
VirtualMachine code, and run the Module with the VirtualMachine, but still have 
no idea to obtain the llvm-ir. Here is my code
```python
from tvm.script import ir as I
from tvm.script import relax as R
import tvm.relax as relax
import tvm
import numpy as np

@I.ir_module
class InputModule:
    @R.function
    def foo(x: R.Tensor((3, 4), "float32"), y: R.Tensor((3, 4), "float32")):
        z = R.add(x, y)
        return z

mod2= InputModule
mod2.show()
target=tvm.target.Target("llvm", host="llvm")
dev = tvm.cpu()
ex=relax.build(mod2, target=target)
vm=relax.VirtualMachine(ex, dev)

data1=tvm.nd.array(np.random.randint(1,2,size=(3,4)).astype(np.float32))
data2=tvm.nd.array(np.random.randint(5,6,size=(3,4)).astype(np.float32))
nd_res=vm["foo"](data1, data2)
print(nd_res)
```
Outputs:[[6. 6. 6. 6.], [6. 6. 6. 6.],[6. 6. .6 .6]]





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/tvm0-20-0-relax-how-to-codegen-llvm-ir-with-relax/18409/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/e5d7d4592cef6e0f8d9818fd540cedf4f8591a474a74bd9868fff3b85d85bc87).

Reply via email to