You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/09/12 10:35:34 UTC

[GitHub] [tvm] cyx-6 opened a new pull request, #12755: [TVMScript] IRBuilder methods for `PrimFunc`

cyx-6 opened a new pull request, #12755:
URL: https://github.com/apache/tvm/pull/12755

   This PR introduces remaining IRBuilder methods for `PrimFunc`.
   
   Co-authored-by: yongwww <yo...@gmail.com>
   


-- 
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] cyx-6 commented on a diff in pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
cyx-6 commented on code in PR #12755:
URL: https://github.com/apache/tvm/pull/12755#discussion_r970314760


##########
python/tvm/script/ir_builder/tir/ir.py:
##########
@@ -65,11 +358,121 @@ def evaluate(value: PrimExpr) -> None:
     return _ffi_api.Evaluate(value)  # pylint: disable=no-member # type: ignore
 
 
+def int8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int8(expr)  # pylint: disable=no-member # type: ignore

Review Comment:
   added



-- 
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] cyx-6 commented on pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
cyx-6 commented on PR #12755:
URL: https://github.com/apache/tvm/pull/12755#issuecomment-1246243022

   > Any updates?
   
   All have been updated.


-- 
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] junrushao commented on a diff in pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12755:
URL: https://github.com/apache/tvm/pull/12755#discussion_r968745060


##########
python/tvm/script/ir_builder/tir/ir.py:
##########
@@ -65,11 +358,121 @@ def evaluate(value: PrimExpr) -> None:
     return _ffi_api.Evaluate(value)  # pylint: disable=no-member # type: ignore
 
 
+def int8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int8(expr)  # pylint: disable=no-member # type: ignore

Review Comment:
   please add some documentation here :-)



-- 
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] cyx-6 commented on a diff in pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
cyx-6 commented on code in PR #12755:
URL: https://github.com/apache/tvm/pull/12755#discussion_r970315645


##########
tests/python/unittest/test_tvmscript_ir_builder_tir.py:
##########
@@ -28,18 +28,40 @@
 def test_ir_builder_tir_primfunc():
     with IRBuilder() as ib:
         with T.prim_func():
+            T.arg("a", T.handle())
+            T.arg("b", T.var("int64"))
+            T.arg("c", T.buffer_decl((128, 128), "float32"))
+            d = T.arg("d", T.handle())
+            e = T.arg("e", T.buffer_decl((1024,), "int8"))
+            T.func_attr({"key": "value"})
+            T.func_ret(tvm.ir.PrimType("int64"))
+            buffer_d = T.match_buffer(d, (64, 64), "int64")
+            T.preflattened_buffer(e, (32, 32), "int8", data=e.data)
             T.evaluate(0)
     # the prim_func generated by IRBuilder
     prim_func_actual = ib.get()
 
     # the expected prim_func
+    c_handle, c_buffer = tir.Var("c_handle", "handle"), tir.decl_buffer(

Review Comment:
   updated



-- 
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] junrushao commented on a diff in pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12755:
URL: https://github.com/apache/tvm/pull/12755#discussion_r968745981


##########
python/tvm/script/ir_builder/tir/ir.py:
##########
@@ -65,11 +358,121 @@ def evaluate(value: PrimExpr) -> None:
     return _ffi_api.Evaluate(value)  # pylint: disable=no-member # type: ignore
 
 
+def int8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int8(expr)  # pylint: disable=no-member # type: ignore
+
+
+def int16(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int16(expr)  # pylint: disable=no-member # type: ignore
+
+
+def int32(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int32(expr)  # pylint: disable=no-member # type: ignore
+
+
+def int64(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int64(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt8(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint16(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt16(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint32(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt32(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint64(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt64(expr)  # pylint: disable=no-member # type: ignore
+
+
+def float8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    if not isinstance(expr, PrimExpr):
+        expr = convert(expr)

Review Comment:
   why doesn't this logic appear in integer conversions above? can we simply remove it assuming the ffi takes care of conversion automatically?



-- 
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] junrushao commented on pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
junrushao commented on PR #12755:
URL: https://github.com/apache/tvm/pull/12755#issuecomment-1246227957

   Any updates?


-- 
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] junrushao merged pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
junrushao merged PR #12755:
URL: https://github.com/apache/tvm/pull/12755


-- 
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] cyx-6 commented on a diff in pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
cyx-6 commented on code in PR #12755:
URL: https://github.com/apache/tvm/pull/12755#discussion_r970315472


##########
python/tvm/script/ir_builder/tir/ir.py:
##########
@@ -65,11 +358,121 @@ def evaluate(value: PrimExpr) -> None:
     return _ffi_api.Evaluate(value)  # pylint: disable=no-member # type: ignore
 
 
+def int8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int8(expr)  # pylint: disable=no-member # type: ignore
+
+
+def int16(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int16(expr)  # pylint: disable=no-member # type: ignore
+
+
+def int32(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int32(expr)  # pylint: disable=no-member # type: ignore
+
+
+def int64(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.Int64(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt8(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint16(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt16(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint32(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt32(expr)  # pylint: disable=no-member # type: ignore
+
+
+def uint64(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    return _ffi_api.UInt64(expr)  # pylint: disable=no-member # type: ignore
+
+
+def float8(expr: Optional[PrimExpr] = None) -> PrimExpr:
+    if not isinstance(expr, PrimExpr):
+        expr = convert(expr)

Review Comment:
   deleted



##########
src/script/ir_builder/tir/utils.h:
##########
@@ -69,6 +69,14 @@ inline BlockFrame FindBlockFrame(const String& method) {
   throw;
 }
 
+inline tvm::tir::BufferRegion BufferRegionFromLoad(tvm::tir::BufferLoad buffer_load) {

Review Comment:
   added



-- 
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] junrushao commented on a diff in pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12755:
URL: https://github.com/apache/tvm/pull/12755#discussion_r968746931


##########
tests/python/unittest/test_tvmscript_ir_builder_tir.py:
##########
@@ -28,18 +28,40 @@
 def test_ir_builder_tir_primfunc():
     with IRBuilder() as ib:
         with T.prim_func():
+            T.arg("a", T.handle())
+            T.arg("b", T.var("int64"))
+            T.arg("c", T.buffer_decl((128, 128), "float32"))
+            d = T.arg("d", T.handle())
+            e = T.arg("e", T.buffer_decl((1024,), "int8"))
+            T.func_attr({"key": "value"})
+            T.func_ret(tvm.ir.PrimType("int64"))
+            buffer_d = T.match_buffer(d, (64, 64), "int64")
+            T.preflattened_buffer(e, (32, 32), "int8", data=e.data)
             T.evaluate(0)
     # the prim_func generated by IRBuilder
     prim_func_actual = ib.get()
 
     # the expected prim_func
+    c_handle, c_buffer = tir.Var("c_handle", "handle"), tir.decl_buffer(

Review Comment:
   always add new tests instead of modifying existing simpler ones



-- 
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] junrushao commented on a diff in pull request #12755: [TVMScript] IRBuilder methods for `PrimFunc`

Posted by GitBox <gi...@apache.org>.
junrushao commented on code in PR #12755:
URL: https://github.com/apache/tvm/pull/12755#discussion_r968746378


##########
src/script/ir_builder/tir/utils.h:
##########
@@ -69,6 +69,14 @@ inline BlockFrame FindBlockFrame(const String& method) {
   throw;
 }
 
+inline tvm::tir::BufferRegion BufferRegionFromLoad(tvm::tir::BufferLoad buffer_load) {

Review Comment:
   let's add some documentation



-- 
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