You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "sunggg (via GitHub)" <gi...@apache.org> on 2023/07/03 22:01:54 UTC
[GitHub] [tvm] sunggg opened a new pull request, #15217: [Unity][BYOC] `PrimValue` handling for `FuseOpByPattern` and BYOC
sunggg opened a new pull request, #15217:
URL: https://github.com/apache/tvm/pull/15217
Currently, `PrimValue` is treated just like a tensors and `FuseOpByPattern` pass creates composite functions that have `PrimValues` as function parameters.
For example, `param_0` and `param_1` are defined to handle `PrimValues`
```Python
@I.ir_module
class Module:
@R.function(private=True)
def fused_relax_clip(x: R.Tensor((10, 10), dtype="float32"), param_0: R.Prim("int64"), param_1: R.Prim("int64")) -> R.Tensor((10, 10), dtype="float32"):
R.func_attr({"Composite": "x.clip", "Primitive": 1})
with R.dataflow():
gv: R.Tensor((10, 10), dtype="float32") = R.clip(x, param_0, param_1)
R.output(gv)
return gv
@R.function
def main(x: R.Tensor((10, 10), dtype="float32")) -> R.Tensor((10, 10), dtype="float32"):
cls = Module
with R.dataflow():
gv: R.Tensor((10, 10), dtype="float32") = cls.fused_relax_clip(x, R.prim_value(0), R.prim_value(4))
R.output(gv)
return gv
```
However, this does not comply with BYOC codegens since they expect each composite function to contain these information that would have been stored in operator attribute before the adoption of `PrimValue`.
Therefore, this PR fixes `FuseOpByPattern` to include `PrimValue` inside the composite function.
With this change, the example above will have the following output.
```Python
@I.ir_module
class Expected1:
@R.function(private=True)
def fused_relax_clip(x: R.Tensor((10, 10), dtype="float32")) -> R.Tensor((10, 10), dtype="float32"):
R.func_attr({"Composite": "x.clip", "Primitive": 1})
with R.dataflow():
gv: R.Tensor((10, 10), dtype="float32") = R.clip(x, R.prim_value(0), R.prim_value(4))
R.output(gv)
return gv
@R.function
def main(x: R.Tensor((10, 10), dtype="float32")) -> R.Tensor((10, 10), dtype="float32"):
cls = Expected1
with R.dataflow():
gv: R.Tensor((10, 10), dtype="float32") = cls.fused_relax_clip(x)
R.output(gv)
return gv
```
cc. @masahi
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] sunggg commented on pull request #15217: [Unity][BYOC] `PrimValue` handling in `FuseOpByPattern` for BYOC
Posted by "sunggg (via GitHub)" <gi...@apache.org>.
sunggg commented on PR #15217:
URL: https://github.com/apache/tvm/pull/15217#issuecomment-1630105519
Now all tests are passed. Shall we merge this? Thank you!
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] sunggg commented on a diff in pull request #15217: [Unity][BYOC] `PrimValue` handling for `FuseOpByPattern` and BYOC
Posted by "sunggg (via GitHub)" <gi...@apache.org>.
sunggg commented on code in PR #15217:
URL: https://github.com/apache/tvm/pull/15217#discussion_r1251304460
##########
src/relax/backend/contrib/codegen_json/codegen_json.h:
##########
@@ -347,7 +347,7 @@ class JSONSerializer : public relax::MemoizedExprTranslator<NodeEntries> {
// TODO(@sunggg): Revisit when we have op naming convention.
// Currently, simply remove "relax." prefix to make it work.
- name = std::string("tensorrt.") + name.substr(6);
+ name = std::string("jsonruntime.") + name.substr(6);
Review Comment:
This is a tiny fix unrelated to this PR.
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tqchen commented on pull request #15217: [Unity][BYOC] `PrimValue` handling in `FuseOpByPattern` for BYOC
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #15217:
URL: https://github.com/apache/tvm/pull/15217#issuecomment-1622218411
cc @masahi
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tvm-bot commented on pull request #15217: [Unity][BYOC] `PrimValue` handling for `FuseOpByPattern` and BYOC
Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #15217:
URL: https://github.com/apache/tvm/pull/15217#issuecomment-1619193672
<!---bot-comment-->
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](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
<!--bot-comment-ccs-start-->
* cc @billishyahao, @quic-sanirudh <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
<sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] masahi merged pull request #15217: [Unity][BYOC] `PrimValue` handling in `FuseOpByPattern` for BYOC
Posted by "masahi (via GitHub)" <gi...@apache.org>.
masahi merged PR #15217:
URL: https://github.com/apache/tvm/pull/15217
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org