tlopex opened a new pull request, #18253:
URL: https://github.com/apache/tvm/pull/18253
This PR implements TVMScript printer to format IRModules containing
@I.pyfunc decorated Python functions.
Example:
```
@I.ir_module
class MyModule(BasePyModule):
@I.pyfunc
def python_func(self, x, y):
x_tvm = self._convert_pytorch_to_tvm(x)
y_tvm = self._convert_pytorch_to_tvm(y)
result = self.call_tir(self.add_tir, [x_tvm, y_tvm],
out_sinfo=R.Tensor((5,), "float32"))
return self._convert_tvm_to_pytorch(result)
@T.prim_func
def add_tir(a: T.handle, b: T.handle, c: T.handle):
A = T.match_buffer(a, (5,), "float32")
B = T.match_buffer(b, (5,), "float32")
C = T.match_buffer(c, (5,), "float32")
for i in range(5):
C[i] = A[i] + B[i]
# Usage:
print(MyModule.script()) # Print formatted TVMScript
MyModule.show() # Display formatted output
```
```
--
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]