This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new bbfc52c  Cleanup more uses of np.bool and np.int. (#8399)
bbfc52c is described below

commit bbfc52c17493e8fefe2e7663b3c3050688f47076
Author: Ramana Radhakrishnan <[email protected]>
AuthorDate: Tue Jul 6 14:53:18 2021 +0100

    Cleanup more uses of np.bool and np.int. (#8399)
    
    In a similar vein to previous pull requests
    replacing deprecated use of np.bool and np.int from
    numpy with bool and int.
    
    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
---
 tests/python/frontend/onnx/test_forward.py               | 16 ++++++++--------
 tests/python/relay/test_op_level4.py                     |  6 +++---
 .../python/test_topi_depthwise_conv2d_back_weight.py     |  4 ++--
 tests/python/unittest/test_tir_nodes.py                  |  4 ++--
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/tests/python/frontend/onnx/test_forward.py 
b/tests/python/frontend/onnx/test_forward.py
index 3c1098c..9a97f89 100644
--- a/tests/python/frontend/onnx/test_forward.py
+++ b/tests/python/frontend/onnx/test_forward.py
@@ -2254,7 +2254,7 @@ def verify_where(condition, x, y, dtype, outdata, 
dynamic=False):
 
 @tvm.testing.uses_gpu
 def test_where():
-    condition = np.array([[1, 0], [1, 1]], dtype=np.bool)
+    condition = np.array([[1, 0], [1, 1]], dtype=bool)
     x = np.array([[1, 2], [3, 4]], dtype=np.int64)
     y = np.array([[9, 8], [7, 6]], dtype=np.int64)
     outdata = np.where(condition, x, y)
@@ -2275,7 +2275,7 @@ def test_where():
     outdata = np.where(condition, x, y)
     verify_where(condition, x, y, TensorProto.FLOAT, outdata)
 
-    condition = np.array(1, dtype=np.bool)
+    condition = np.array(1, dtype=bool)
     x = np.array([[1, 2], [3, 4]], dtype=np.float32)
     y = np.array([[5, 6], [7, 8]], dtype=np.float32)
     outdata = np.where(condition, x, y)
@@ -3965,7 +3965,7 @@ def verify_cond_loop():
 
     trip_count = np.array(5).astype(np.int64)
     res_y = np.array([13]).astype(np.float32)
-    cond = np.array(1).astype(np.bool)
+    cond = np.array(1).astype(bool)
     loop_graph = onnx.helper.make_graph(
         [loop_node],
         "loop_outer",
@@ -3983,7 +3983,7 @@ def verify_cond_loop():
 
     # Set a high trip count so that condition trips first.
     trip_count = np.array(40).astype(np.int64)
-    cond = np.array(1).astype(np.bool)
+    cond = np.array(1).astype(bool)
     input_vals = [trip_count, cond, y]
     verify_with_ort_with_inputs(loop_model, input_vals, use_vm=True, 
freeze_params=True)
 
@@ -4021,7 +4021,7 @@ def verify_count_loop():
 
     trip_count = np.array(5).astype(np.int64)
     res_y = np.array([13]).astype(np.float32)
-    cond = np.array(1).astype(np.bool)
+    cond = np.array(1).astype(bool)
     loop_graph = onnx.helper.make_graph(
         [loop_node],
         "loop_outer",
@@ -4038,7 +4038,7 @@ def verify_count_loop():
     loop_model = onnx.helper.make_model(loop_graph)
 
     trip_count = np.array(5).astype(np.int64)
-    cond = np.array(1).astype(np.bool)
+    cond = np.array(1).astype(bool)
     input_vals = [trip_count, cond, y]
     verify_with_ort_with_inputs(loop_model, input_vals, use_vm=True, 
freeze_params=True)
 
@@ -4075,7 +4075,7 @@ def verify_tensor_loop():
     )
 
     trip_count = np.array(5).astype(np.int64)
-    cond = np.array(1).astype(np.bool)
+    cond = np.array(1).astype(bool)
     loop_graph = onnx.helper.make_graph(
         [loop_node],
         "loop_outer",
@@ -4092,7 +4092,7 @@ def verify_tensor_loop():
     loop_model = onnx.helper.make_model(loop_graph)
 
     trip_count = np.array(5).astype(np.int64)
-    cond = np.array(1).astype(np.bool)
+    cond = np.array(1).astype(bool)
     input_vals = [trip_count, cond, y]
     verify_with_ort_with_inputs(
         loop_model, input_vals, use_vm=True, freeze_params=True, 
convert_to_static=True
diff --git a/tests/python/relay/test_op_level4.py 
b/tests/python/relay/test_op_level4.py
index c4d26a1..b59325a 100644
--- a/tests/python/relay/test_op_level4.py
+++ b/tests/python/relay/test_op_level4.py
@@ -189,7 +189,7 @@ def test_where():
 
     x_np = np.array(1.0, dtype)
     y_np = np.array(-1.0, dtype)
-    cond_np = np.array([1, 0, 1], dtype=np.bool)
+    cond_np = np.array([1, 0, 1], dtype=bool)
 
     verify(x_np, y_np, cond_np)
 
@@ -201,7 +201,7 @@ def test_where():
 
     x_np = np.array([[1, 2], [3, 4]], dtype)
     y_np = np.array([[5, 6], [7, 8]], dtype)
-    cond_np = np.array([[1], [0]], dtype=np.bool)
+    cond_np = np.array([[1], [0]], dtype=bool)
 
     verify(x_np, y_np, cond_np)
     verify(x_np, y_np, cond_np.T)
@@ -213,7 +213,7 @@ def test_where():
     verify(x_np, y_np, cond_np)
 
     x_np, y_np = np.ogrid[:3, :4]
-    cond_np = np.where(x_np < y_np, x_np, 10 + y_np).astype(np.bool)
+    cond_np = np.where(x_np < y_np, x_np, 10 + y_np).astype(bool)
 
     verify(x_np.astype(dtype), y_np.astype(dtype), cond_np)
 
diff --git a/tests/python/topi/python/test_topi_depthwise_conv2d_back_weight.py 
b/tests/python/topi/python/test_topi_depthwise_conv2d_back_weight.py
index 8e30ed68..0bbb0e6 100644
--- a/tests/python/topi/python/test_topi_depthwise_conv2d_back_weight.py
+++ b/tests/python/topi/python/test_topi_depthwise_conv2d_back_weight.py
@@ -36,8 +36,8 @@ def verify_depthwise_conv2d_back_weight(
     stride_w = stride_h
     padding_w = padding_h
 
-    out_h = np.int((in_h + 2 * padding_h - filter_h) / stride_h + 1)
-    out_w = np.int((in_w + 2 * padding_w - filter_w) / stride_w + 1)
+    out_h = int((in_h + 2 * padding_h - filter_h) / stride_h + 1)
+    out_w = int((in_w + 2 * padding_w - filter_w) / stride_w + 1)
     out_channel = in_channel * channel_multiplier
 
     oshape = [batch, out_h, out_w, out_channel]
diff --git a/tests/python/unittest/test_tir_nodes.py 
b/tests/python/unittest/test_tir_nodes.py
index 89ca9ac..07a82ba 100644
--- a/tests/python/unittest/test_tir_nodes.py
+++ b/tests/python/unittest/test_tir_nodes.py
@@ -29,7 +29,7 @@ def test_const():
 def test_scalar_dtype_inference():
     for data in [
         True,
-        np.bool(1),
+        bool(1),
         np.uint8(1),
         np.uint16(1),
         np.uint32(1),
@@ -48,7 +48,7 @@ def test_scalar_dtype_inference():
 
     for data in [
         True,
-        np.bool(1),
+        bool(1),
         np.uint8(1),
         np.uint16(1),
         np.uint32(1),

Reply via email to