diff --git a/test/quantization/core/test_quantized_op.py b/test/quantization/core/test_quantized_op.py index 58a7ed4d692..ed37552e1ce 100644 --- a/test/quantization/core/test_quantized_op.py +++ b/test/quantization/core/test_quantized_op.py @@ -3007,7 +3007,7 @@ class TestDynamicQuantizedOps(TestCase): # W_scale = 1.0 # W_zp = 0 W_scales = np.ones(output_channels) - W_zps = np.zeros(output_channels).astype(np.int) + W_zps = np.zeros(output_channels).astype(int) W_value_min = -128 W_value_max = 127 W_q0 = np.round( @@ -3571,9 +3571,9 @@ class TestQuantizedLinear(TestCase): # xnnpack forces W_zp to 0 when using symmetric quantization # ONEDNN only supports symmetric quantization of weight if dtype == torch.qint8 or qengine_is_onednn(): - W_zps = np.zeros(output_channels).astype(np.int) + W_zps = np.zeros(output_channels).astype(int) else: - W_zps = np.round(np.random.rand(output_channels) * 100 - 50).astype(np.int) + W_zps = np.round(np.random.rand(output_channels) * 100 - 50).astype(int) # when using symmetric quantization # special restriction for xnnpack fully connected op weight # [-127, 127] instead of [-128, 127] diff --git a/test/test_reductions.py b/test/test_reductions.py index 08d951154ff..22b019c0090 100644 --- a/test/test_reductions.py +++ b/test/test_reductions.py @@ -1434,7 +1434,7 @@ class TestReductions(TestCase): vals = [[True, True], [True, False], [False, False], []] for val in vals: result = torch.prod(torch.tensor(val, device=device), dtype=torch.bool).item() - expect = np.prod(np.array(val), dtype=np.bool) + expect = np.prod(np.array(val), dtype=bool) self.assertEqual(result, expect) result = torch.prod(torch.tensor(val, device=device)).item() diff --git a/test/test_tensor_creation_ops.py b/test/test_tensor_creation_ops.py index 69b2f2c8034..4018b9184cb 100644 --- a/test/test_tensor_creation_ops.py +++ b/test/test_tensor_creation_ops.py @@ -1444,14 +1444,14 @@ class TestTensorCreation(TestCase): def test_ctor_with_numpy_array(self, device): correct_dtypes = [ np.double, - np.float, + float, np.float16, np.int64, np.int32, np.int16, np.int8, np.uint8, - np.bool, + bool, ] incorrect_byteorder = '>' if sys.byteorder == 'little' else '<' diff --git a/test/test_tensorboard.py b/test/test_tensorboard.py index 0ba38cdceed..5d2ef1ee4df 100644 --- a/test/test_tensorboard.py +++ b/test/test_tensorboard.py @@ -807,7 +807,7 @@ class TestTensorBoardNumpy(BaseTestCase): model = ModelHelper(name="mnist") # how come those inputs don't break the forward pass =.=a workspace.FeedBlob("data", np.random.randn(1, 3, 64, 64).astype(np.float32)) - workspace.FeedBlob("label", np.random.randn(1, 1000).astype(np.int)) + workspace.FeedBlob("label", np.random.randn(1, 1000).astype(int)) with core.NameScope("conv1"): conv1 = brew.conv(model, "data", 'conv1', dim_in=1, dim_out=20, kernel=5) @@ -842,7 +842,7 @@ class TestTensorBoardNumpy(BaseTestCase): def test_caffe2_simple_cnnmodel(self): model = cnn.CNNModelHelper("NCHW", name="overfeat") workspace.FeedBlob("data", np.random.randn(1, 3, 64, 64).astype(np.float32)) - workspace.FeedBlob("label", np.random.randn(1, 1000).astype(np.int)) + workspace.FeedBlob("label", np.random.randn(1, 1000).astype(int)) with core.NameScope("conv1"): conv1 = model.Conv("data", "conv1", 3, 96, 11, stride=4) relu1 = model.Relu(conv1, conv1) diff --git a/test/test_torch.py b/test/test_torch.py index 7069ccca960..cd933f08769 100644 --- a/test/test_torch.py +++ b/test/test_torch.py @@ -6367,7 +6367,7 @@ class TestTorch(TestCase): # fail parse with float variables self.assertRaises(TypeError, lambda: torch.ones((torch.tensor(3.), torch.tensor(4)))) # fail parse with numpy floats - self.assertRaises(TypeError, lambda: torch.ones((np.float(3.), torch.tensor(4)))) + self.assertRaises(TypeError, lambda: torch.ones((3., torch.tensor(4)))) self.assertRaises(TypeError, lambda: torch.ones((np.array(3.), torch.tensor(4)))) # fail parse with > 1 element variables diff --git a/torch/utils/tensorboard/summary.py b/torch/utils/tensorboard/summary.py index 533b651d00a..08e42e01c78 100644 --- a/torch/utils/tensorboard/summary.py +++ b/torch/utils/tensorboard/summary.py @@ -380,6 +380,7 @@ def make_histogram(values, bins, max_bins=None): limits = new_limits # Find the first and the last bin defining the support of the histogram: + cum_counts = np.cumsum(np.greater(counts, 0)) start, end = np.searchsorted(cum_counts, [0, cum_counts[-1] - 1], side="right") start = int(start)