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/07/24 23:54:37 UTC

[GitHub] [tvm] cconvey opened a new pull request, #12168: [hexagon][testing] sequential input tensors

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

   Provide mechanism to let unit tests initialize
   input tensors with sequential element values.
   Useful for debugging.
   


-- 
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] areusch commented on a diff in pull request #12168: [hexagon][testing] sequential input tensors

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


##########
tests/python/contrib/test_hexagon/pytest_util.py:
##########
@@ -109,25 +113,32 @@ def get_multitest_ids(
     ]
 
 
-def get_numpy_dtype_info(np_dtype_name: str) -> Union[np.finfo, np.iinfo]:
+def get_numpy_dtype_info(dtype: Union[str, np.dtype]) -> Union[np.finfo, np.iinfo]:
     """
     Return an appropriate 'np.iinfo' or 'np.finfo' object corresponding to
-    the specified dtype.
+    the specified Numpy dtype.
     """
-    np_dtype = np.dtype(np_dtype_name)
+
+    if type(dtype) == str:

Review Comment:
   isinstance(dtype, str)



##########
tests/python/contrib/test_hexagon/pytest_util.py:
##########
@@ -109,25 +113,32 @@ def get_multitest_ids(
     ]
 
 
-def get_numpy_dtype_info(np_dtype_name: str) -> Union[np.finfo, np.iinfo]:
+def get_numpy_dtype_info(dtype: Union[str, np.dtype]) -> Union[np.finfo, np.iinfo]:
     """
     Return an appropriate 'np.iinfo' or 'np.finfo' object corresponding to
-    the specified dtype.
+    the specified Numpy dtype.
     """
-    np_dtype = np.dtype(np_dtype_name)
+
+    if type(dtype) == str:
+        np_dtype = np.dtype(np_dtype_name)
+    else:
+        assert isinstance(dtype, np.dtype)

Review Comment:
   can you add an explainer when this assert fails:
   ```suggestion
           assert isinstance(dtype, np.dtype), f"dtype: want str or np.dtype, got {dtype!r}"
   ```



##########
tests/python/contrib/test_hexagon/pytest_util.py:
##########
@@ -155,5 +166,15 @@ def create_populated_numpy_ndarray(
     elif type(itp) == TensorContentRandom:
         return np.random.random(input_shape).astype(dtype)
 
+    elif type(itp) == TensorContentSequentialCOrder:
+        a = np.empty(tuple(input_shape), dtype)
+
+        with np.nditer(a, op_flags=["writeonly"], order="C") as it:

Review Comment:
   wondering if this should get a unittest



-- 
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] csullivan merged pull request #12168: [hexagon][testing] sequential input tensors

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


-- 
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] cconvey commented on a diff in pull request #12168: [hexagon][testing] sequential input tensors

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


##########
tests/python/contrib/test_hexagon/pytest_util.py:
##########
@@ -109,25 +113,32 @@ def get_multitest_ids(
     ]
 
 
-def get_numpy_dtype_info(np_dtype_name: str) -> Union[np.finfo, np.iinfo]:
+def get_numpy_dtype_info(dtype: Union[str, np.dtype]) -> Union[np.finfo, np.iinfo]:
     """
     Return an appropriate 'np.iinfo' or 'np.finfo' object corresponding to
-    the specified dtype.
+    the specified Numpy dtype.
     """
-    np_dtype = np.dtype(np_dtype_name)
+
+    if type(dtype) == str:

Review Comment:
   Good idea.  I put the assert there because AFAIK Python `typing` typically isn't checked at runtime.  So I put the assertion there to help detect such problems.
   
   But in retrospect, that's not particularly idiomatic.  I'll just delete the assert.



-- 
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] cconvey commented on a diff in pull request #12168: [hexagon][testing] sequential input tensors

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


##########
tests/python/contrib/test_hexagon/pytest_util.py:
##########
@@ -109,25 +113,32 @@ def get_multitest_ids(
     ]
 
 
-def get_numpy_dtype_info(np_dtype_name: str) -> Union[np.finfo, np.iinfo]:
+def get_numpy_dtype_info(dtype: Union[str, np.dtype]) -> Union[np.finfo, np.iinfo]:
     """
     Return an appropriate 'np.iinfo' or 'np.finfo' object corresponding to
-    the specified dtype.
+    the specified Numpy dtype.
     """
-    np_dtype = np.dtype(np_dtype_name)
+
+    if type(dtype) == str:

Review Comment:
   Actually, a better solution is to drop the explicit typing, and just document that that arg needs to be something that Numpy can deal with.  I'll make that change 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] cconvey commented on a diff in pull request #12168: [hexagon][testing] sequential input tensors

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


##########
tests/python/contrib/test_hexagon/pytest_util.py:
##########
@@ -155,5 +166,15 @@ def create_populated_numpy_ndarray(
     elif type(itp) == TensorContentRandom:
         return np.random.random(input_shape).astype(dtype)
 
+    elif type(itp) == TensorContentSequentialCOrder:
+        a = np.empty(tuple(input_shape), dtype)
+
+        with np.nditer(a, op_flags=["writeonly"], order="C") as it:

Review Comment:
   > is should get a unittest
   
   I was on the fence about that.  I did test it manually, but I thought unit testing a little debug-assist like this might be overkill.



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