You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tvm.apache.org by wrongtest via Apache TVM Discuss <no...@discuss.tvm.ai> on 2022/02/18 08:23:04 UTC

[Apache TVM Discuss] [Development] Can we lift tir.AttrStmt value type to ObjectRef?


Schedule annotations of `For` and `Block` are all Map<String, ObjectRef>. But certain pragma annotations can not get lowerer to `T.attr`,only those of expression typed values are allowed.





---
[Visit Topic](https://discuss.tvm.apache.org/t/can-we-lift-tir-attrstmt-value-type-to-objectref/12118/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/8ba395d87a58f7e1de0701b3c29cdeff40e371ba967d04b7606878cfd85656d9).

[Apache TVM Discuss] [Development] Can we lift tir.AttrStmt value type to ObjectRef?

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

Hi~ I think this is not the issue of tvmscript. For example, though `List[Integer]` is supported by script, it would fail in lowering with `Illegal attribute of key pragma_key, value type Array not supported`, since the annotation can not convert to an attr stmt.   
```python
import tvm
from tvm.script import tir as T

@T.prim_func
def fun(x: T.Buffer((16,), "int32")) -> None:
    for k in T.serial(0, 16, annotations={"pragma_key": [1, 2, 3]}):
        x[k] = 1

print(tvm.lower(fun).script())
```





---
[Visit Topic](https://discuss.tvm.apache.org/t/can-we-lift-tir-attrstmt-value-type-to-objectref/12118/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/7d3cf1a0358a40badecc66e9eb85d7fe7c916f2186f2077304c4c8f8da00f826).

[Apache TVM Discuss] [Development] Can we lift tir.AttrStmt value type to ObjectRef?

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

[quote="wrongtest, post:1, topic:12118"]
But certain pragma annotations can not get lowerer to `T.attr`,only those of expression typed values are allowed
[/quote]

Would you like to elaborate? Currently the type of `AttrStmtNode::value` is `PrimExpr`, but which type cannot be supported by TVMScript printer and why?





---
[Visit Topic](https://discuss.tvm.apache.org/t/can-we-lift-tir-attrstmt-value-type-to-objectref/12118/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/0aefb8f794b3b72f4493412ccd54283b05697b96290001c73c7af4ac13c1a8b1).

[Apache TVM Discuss] [Development] Can we lift tir.AttrStmt value type to ObjectRef?

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

AttrStmt was our historical way to create extensions. While it offered quite some convenience, it also created a dilemma that it may introduce new language extensions that may become incompatible with the existing semantics. e.g. an old pass may no longer be compatible with a new extension semantics.

Moving forward, we ideally would like to think about these extension points in a more structured way:

- `annotations` in blocks and for loops are "hints" to the program transformations about what can be done, which means they can be safely ignored (e.g. a parallel for annotation) by most of the transformations. This enables most passes to safely ignore annotations when possible. Importantly, the object in annotations are all **constant**(so we do not need to worry about mutating its value when we change the IR).
- When there are possible operations that changes the semantics of the execution block, we would like to be explicit and consider IR change that would require examination of all pass compatibility(e.g. While loop, bound of a variable which depends on other variables.)

Given AttrStmt was the legacy extension point we might want to leave it was it is and deprecate(or restrict to annotations) as we continue to improve the lowering. In the meantime, we can try to leverage annotation fields for new code generation behaviors.





---
[Visit Topic](https://discuss.tvm.apache.org/t/can-we-lift-tir-attrstmt-value-type-to-objectref/12118/5) 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/b6c138d1d8e0fde7150ef3a58d6ddb270894647dfc8b68e05f994ba16c635c57).

[Apache TVM Discuss] [Development] Can we lift tir.AttrStmt value type to ObjectRef?

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

This is definitely interesting usecases which unifies "AttrStmt" with definitions of Attr otherwhere in the codebase. Given `AttrStmt` is something we wanted to move away from, I would love to confirm with @tqchen that the change is acceptable





---
[Visit Topic](https://discuss.tvm.apache.org/t/can-we-lift-tir-attrstmt-value-type-to-objectref/12118/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/7b174a4bd172ff097c88077e1e469e32d8dce812db766f6facf8b515413950a8).