vinx13 commented on a change in pull request #9432:
URL: https://github.com/apache/tvm/pull/9432#discussion_r742258491



##########
File path: python/tvm/script/tir/__init__.pyi
##########
@@ -0,0 +1,239 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=redefined-builtin
+from typing import (
+    Any,
+    Callable,
+    ContextManager,
+    Dict,
+    Iterable,
+    Object,
+    Optional,
+    Tuple,
+    Union,
+    Sequence,
+    List,
+    Mapping,
+)
+from tvm.tir.function import PrimFunc
+from tvm.tir import PrimExpr, Buffer, IterVar, Var
+from .node import BufferSlice
+
+"""
+Variables and constants
+"""
+
+def bool(imm: int) -> PrimExpr: ...

Review comment:
       imm should has type Union[PrimExpr, bool, Number]

##########
File path: python/tvm/script/tir/__init__.pyi
##########
@@ -0,0 +1,239 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=redefined-builtin
+from typing import (
+    Any,
+    Callable,
+    ContextManager,
+    Dict,
+    Iterable,
+    Object,
+    Optional,
+    Tuple,
+    Union,
+    Sequence,
+    List,
+    Mapping,
+)
+from tvm.tir.function import PrimFunc
+from tvm.tir import PrimExpr, Buffer, IterVar, Var
+from .node import BufferSlice
+
+"""
+Variables and constants
+"""
+
+def bool(imm: int) -> PrimExpr: ...
+def int8(imm: int) -> PrimExpr: ...

Review comment:
       (for this function and below) `imm: Union[PrimExpr, Number]`

##########
File path: mypy.ini
##########
@@ -23,6 +23,14 @@ follow_imports = skip
 ignore_errors = False
 strict_optional = False
 
+#
+# Note: not all tests under .tests/ are typed 
+# Therefore include test files that should be
+# checked by mypy here
+#
+files = 
+    tests/python/unittest/test_tvmscript_type.py

Review comment:
       I'd prefer adding the command to 
https://github.com/apache/tvm/blob/main/tests/scripts/task_mypy.sh
   My concern is that adding it in the config file is not as explicit as adding 
in a centralized file of test commands. Also  IIUC this implies check the 
specified file every time running Mypy (even if it is intended to type check 
other modules)

##########
File path: python/tvm/script/tir/__init__.pyi
##########
@@ -0,0 +1,239 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=redefined-builtin
+from typing import (
+    Any,
+    Callable,
+    ContextManager,
+    Dict,
+    Iterable,
+    Object,
+    Optional,
+    Tuple,
+    Union,
+    Sequence,
+    List,
+    Mapping,
+)
+from tvm.tir.function import PrimFunc
+from tvm.tir import PrimExpr, Buffer, IterVar, Var
+from .node import BufferSlice
+
+"""
+Variables and constants
+"""
+
+def bool(imm: int) -> PrimExpr: ...
+def int8(imm: int) -> PrimExpr: ...
+def int16(imm: int) -> PrimExpr: ...
+def int32(imm: int) -> PrimExpr: ...
+def int64(imm: int) -> PrimExpr: ...
+def uint8(imm: int) -> PrimExpr: ...
+def uint16(imm: int) -> PrimExpr: ...
+def uint32(imm: int) -> PrimExpr: ...
+def uint64(imm: int) -> PrimExpr: ...
+def float8(imm: int) -> PrimExpr: ...
+def float16(imm: int) -> PrimExpr: ...
+def float32(imm: int) -> PrimExpr: ...
+def float64(imm: int) -> PrimExpr: ...
+
+"""
+Intrinsic
+"""
+
+def min_value(dtype): ...
+def max_value(dtype): ...
+def floordiv(x: PrimExpr, y: PrimExpr): ...
+def floormod(x: PrimExpr, y: PrimExpr): ...
+def abs(x): ...
+def load(dtype, var, index, predicate=None): ...
+def cast(value, dtype): ...
+def ramp(base, stride, lanes): ...
+def broadcast(value, lanes): ...
+def iter_var(var, dom, iter_type, thread_tag): ...
+def max(a, b): ...
+def min(a, b): ...
+def get_axis(begin, end, iter_type): ...
+def range(begin, end): ...

Review comment:
       duplicated with definitions below 

##########
File path: tests/python/unittest/test_tvmscript_type.py
##########
@@ -0,0 +1,61 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# pylint: disable=missing-function-docstring,missing-module-docstring
+import sys
+import pytest
+import tvm
+from tvm import tir
+from tvm.script import tir as T
+
+"""
+This module tests the type of
+T.prim_func, T.handle, T.match_buffer, T.block
+T.reads, T.writes, T.alloc_buffer, T.serial
+T.block_attr, T.float32
+"""
+
+
[email protected]_testing

Review comment:
       remove this as 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to