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/08/26 20:17:18 UTC

[GitHub] [tvm] shingjan opened a new pull request, #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

shingjan opened a new pull request, #12618:
URL: https://github.com/apache/tvm/pull/12618

   As mentioned in #12617 , this PR intends to provide support of float inf, -inf and nan in TVMScript parser and printer.
   
   cc: @zxybazh @junrushao 
   


-- 
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] shingjan commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/__init__.pyi:
##########
@@ -464,14 +464,19 @@ class uint32(PrimExpr):
 class uint64(PrimExpr):
     def __init__(self: uint64, imm: Union[PrimExpr, int]): ...
 
+# use typing.Literal instead for python 3.8 or higher
+from typing_extensions import Literal

Review Comment:
   Sounds good. This is changed. Since `Enum` seems like an overkill I just keep the `SpecialFloatLiteral = str` here instead of `class SpecialFloatLiteral(Enum)`



-- 
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] vinx13 commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/intrin.py:
##########
@@ -51,6 +52,13 @@ def bool(imm, span):
             # nest closures so we copy the name string
             def wrap(name):
                 def f(imm, span):
+                    if name.startswith("float"):
+                        if imm == "inf":

Review Comment:
   what's the type of imm? can we do `FloatImm(dtype=name, value=float(imm), span=span)` instead?



-- 
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] shingjan commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/__init__.pyi:
##########
@@ -465,13 +465,13 @@ class uint64(PrimExpr):
     def __init__(self: uint64, imm: Union[PrimExpr, int]): ...
 
 class float8(PrimExpr):
-    def __init__(self: float8, imm: Union[PrimExpr, int, float]): ...
+    def __init__(self: float8, imm: Union[PrimExpr, int, float, str]): ...

Review Comment:
   right now tvm only requires python >= 3.6, which means `Literal` may not be available if python <3.8 is used. What about we put something like `SpecialFloatLiteral: str = str["inf", "-inf", "nan"]` until python>=3.8 is implemented in tvm?



-- 
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] shingjan commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/intrin.py:
##########
@@ -51,6 +52,13 @@ def bool(imm, span):
             # nest closures so we copy the name string
             def wrap(name):
                 def f(imm, span):
+                    if name.startswith("float"):
+                        if imm == "inf":

Review Comment:
   `imm` is str. This is addressed.



-- 
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] shingjan commented on pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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

   @tvm-bot rerun


-- 
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] shingjan commented on pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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

   Thanks @vinx13 !


-- 
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] vinx13 commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/__init__.pyi:
##########
@@ -464,14 +464,19 @@ class uint32(PrimExpr):
 class uint64(PrimExpr):
     def __init__(self: uint64, imm: Union[PrimExpr, int]): ...
 
+# use typing.Literal instead for python 3.8 or higher
+from typing_extensions import Literal

Review Comment:
   I think it's be better to avoid extra dependency. We can check the sys version and upgrade to 3.8 sometime in the future
   ```
   if sys.version_info >= (3, 8):
     SpecialFloatLiteral = ...
   else:
     SpecialFloatLiteral = str
   ```
   



-- 
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] vinx13 commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/__init__.pyi:
##########
@@ -465,13 +465,13 @@ class uint64(PrimExpr):
     def __init__(self: uint64, imm: Union[PrimExpr, int]): ...
 
 class float8(PrimExpr):
-    def __init__(self: float8, imm: Union[PrimExpr, int, float]): ...
+    def __init__(self: float8, imm: Union[PrimExpr, int, float, str]): ...

Review Comment:
   would be better to explicitly define a list of special literals:
   ```
   SpecialFloatLiteral = Literal["inf", "-inf", "nan"]
   ```



-- 
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] vinx13 commented on pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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

   https://github.com/apache/tvm/blob/main/python/tvm/script/tir/__init__.pyi#L467-L477 should also be 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] vinx13 commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
src/printer/tvmscript_printer.cc:
##########
@@ -381,18 +381,17 @@ class TVMScriptPrinter : public StmtFunctor<Doc(const Stmt&)>,
   }
 
   /*!
-   * \brief special method to print out const scalar
+   * \brief special method to print out const int64_t scalar
    * \param dtype The data type
    * \param data The pointer to hold the data.
    */
   template <typename T>

Review Comment:
   remove it since it's not needed



-- 
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] vinx13 commented on pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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

   CI error is related


-- 
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] vinx13 merged pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


-- 
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] vinx13 commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/__init__.pyi:
##########
@@ -465,13 +465,13 @@ class uint64(PrimExpr):
     def __init__(self: uint64, imm: Union[PrimExpr, int]): ...
 
 class float8(PrimExpr):
-    def __init__(self: float8, imm: Union[PrimExpr, int, float]): ...
+    def __init__(self: float8, imm: Union[PrimExpr, int, float, str]): ...

Review Comment:
   Sounds good



-- 
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] shingjan commented on a diff in pull request #12618: [TVMScript] support float inf, -inf and nan in TVMScript parser and printer

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


##########
python/tvm/script/tir/__init__.pyi:
##########
@@ -465,13 +465,13 @@ class uint64(PrimExpr):
     def __init__(self: uint64, imm: Union[PrimExpr, int]): ...
 
 class float8(PrimExpr):
-    def __init__(self: float8, imm: Union[PrimExpr, int, float]): ...
+    def __init__(self: float8, imm: Union[PrimExpr, int, float, str]): ...

Review Comment:
   seems like `typing_extension.Literal` can be used for python < 3.8. This is 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