diff --git a/caffe2/python/core_test.py b/caffe2/python/core_test.py index 6a8c0d7d3ca1bb..13cde2475f64e8 100644 --- a/caffe2/python/core_test.py +++ b/caffe2/python/core_test.py @@ -255,25 +255,25 @@ class TestExternalInputs(test_util.TestCase): def testAddExternalInputShouldRaiseIfDuplicate(self): net = core.Net("test") net.AddExternalInput( - schema.Struct(("x", schema.Scalar(np.float))), + schema.Struct(("x", schema.Scalar(np.float64))), ) with self.assertRaises(AssertionError): net.AddExternalInput( - schema.Struct(("x", schema.Scalar(np.float))), + schema.Struct(("x", schema.Scalar(np.float64))), ) def testAddExternalInputShouldRaiseIfDuplicateInSameCall(self): net = core.Net("test") with self.assertRaises(AssertionError): net.AddExternalInput( - schema.Struct(("x", schema.Scalar(np.float))), - schema.Struct(("x", schema.Scalar(np.float))), + schema.Struct(("x", schema.Scalar(np.float64))), + schema.Struct(("x", schema.Scalar(np.float64))), ) def testSetInputRecordWithBlobs(self): net = core.Net("test") record = schema.NewRecord(net, schema.Struct( - ("x", schema.Scalar(np.float)), + ("x", schema.Scalar(np.float64)), )) input_record = net.set_input_record(record) self.assertTrue(net.BlobIsDefined(input_record.x())) @@ -281,7 +281,7 @@ def testSetInputRecordWithBlobs(self): def testSetInputRecordWithoutBlobs(self): net = core.Net("test") - record = schema.Struct(("x", schema.Scalar(np.float))) + record = schema.Struct(("x", schema.Scalar(np.float64))) input_record = net.set_input_record(record) self.assertTrue(net.BlobIsDefined(input_record.x())) self.assertIn(input_record.x(), net.external_inputs) diff --git a/caffe2/python/layer_model_helper.py b/caffe2/python/layer_model_helper.py index c5dc6f198d273f..017e2ed2f043f6 100644 --- a/caffe2/python/layer_model_helper.py +++ b/caffe2/python/layer_model_helper.py @@ -124,7 +124,7 @@ def add_ad_hoc_plot_blob(self, blob, dtype=None): assert isinstance( blob, (str, core.BlobReference) ), "expect type str or BlobReference, but got {}".format(type(blob)) - dtype = dtype or (np.float, (1, )) + dtype = dtype or (np.float64, (1, )) self.add_metric_field(str(blob), schema.Scalar(dtype, blob)) self.ad_hoc_plot_blobs.append(blob) diff --git a/caffe2/python/modeling/compute_norm_for_blobs.py b/caffe2/python/modeling/compute_norm_for_blobs.py index 24ed7a7482c708..010e01dffcf225 100644 --- a/caffe2/python/modeling/compute_norm_for_blobs.py +++ b/caffe2/python/modeling/compute_norm_for_blobs.py @@ -81,7 +81,7 @@ def modify_net(self, net, init_net=None, grad_map=None, blob_to_device=None, if modify_output_record: output_field_name = str(blob) + self._field_name_suffix - output_scalar = schema.Scalar((np.float, (1,)), norm) + output_scalar = schema.Scalar((np.float64, (1,)), norm) if net.output_record() is None: net.set_output_record( diff --git a/caffe2/python/modeling/compute_statistics_for_blobs.py b/caffe2/python/modeling/compute_statistics_for_blobs.py index 588b4a827cb82b..590b050469f062 100644 --- a/caffe2/python/modeling/compute_statistics_for_blobs.py +++ b/caffe2/python/modeling/compute_statistics_for_blobs.py @@ -39,7 +39,7 @@ def modify_net(self, net, init_net=None, grad_map=None, blob_to_device=None, if modify_output_record: output_field_name = str(blob) + self._field_name_suffix - output_scalar = schema.Scalar((np.float, (1,)), stats) + output_scalar = schema.Scalar((np.float64, (1,)), stats) if net.output_record() is None: net.set_output_record( diff --git a/caffe2/python/modeling/get_entry_from_blobs.py b/caffe2/python/modeling/get_entry_from_blobs.py index 061dfe33991bbd..ff59bc6974dc06 100644 --- a/caffe2/python/modeling/get_entry_from_blobs.py +++ b/caffe2/python/modeling/get_entry_from_blobs.py @@ -70,7 +70,7 @@ def modify_net(self, net, init_net=None, grad_map=None, blob_to_device=None, if modify_output_record: output_field_name = str(blob) + self._field_name_suffix - output_scalar = schema.Scalar((np.float), blob_i1_i2) + output_scalar = schema.Scalar((np.float64), blob_i1_i2) if net.output_record() is None: net.set_output_record( diff --git a/caffe2/python/operator_test/concat_op_cost_test.py b/caffe2/python/operator_test/concat_op_cost_test.py index 7dab4d6bd5d1f1..065a22569992f9 100644 --- a/caffe2/python/operator_test/concat_op_cost_test.py +++ b/caffe2/python/operator_test/concat_op_cost_test.py @@ -38,7 +38,7 @@ def _test_columnwise_concat_for_type(dtype): [ _test_columnwise_concat_for_type(t) - for t in [np.int64, np.float, np.half, np.int8] + for t in [np.int64, np.float64, np.half, np.int8] ] def test_split_then_concat(self): diff --git a/caffe2/python/operator_test/dropout_op_test.py b/caffe2/python/operator_test/dropout_op_test.py index 11bc7bde329f7c..6837b013fe343e 100644 --- a/caffe2/python/operator_test/dropout_op_test.py +++ b/caffe2/python/operator_test/dropout_op_test.py @@ -101,7 +101,7 @@ def test_dropout_ratio1(self, X, in_place, output_mask, engine, gc, dc): self.assertGradientChecks(gc, op, [X], 0, [0]) def reference_dropout_ratio1(x): - return (x,) if is_test else (np.zeros(x.shape, dtype=np.float), np.zeros(x.shape, dtype=bool)) + return (x,) if is_test else (np.zeros(x.shape, dtype=np.float64), np.zeros(x.shape, dtype=bool)) self.assertReferenceChecks( gc, op, [X], reference_dropout_ratio1, # Don't check the mask with cuDNN because it's packed data diff --git a/caffe2/python/operator_test/feature_maps_ops_test.py b/caffe2/python/operator_test/feature_maps_ops_test.py index b4b2cc2c427797..aed2168c0f53c3 100644 --- a/caffe2/python/operator_test/feature_maps_ops_test.py +++ b/caffe2/python/operator_test/feature_maps_ops_test.py @@ -23,7 +23,7 @@ def test_merge_dense_feature_tensors(self): # Input 1. workspace.FeedBlob( "in1", - np.array([[11.1, 12.1, 13.1, 14.1], [11.2, 12.2, 13.2, 14.2]], dtype=np.float) + np.array([[11.1, 12.1, 13.1, 14.1], [11.2, 12.2, 13.2, 14.2]], dtype=np.float64) ) workspace.FeedBlob( "in1_presence", @@ -42,7 +42,7 @@ def test_merge_dense_feature_tensors(self): ) np.testing.assert_array_equal( workspace.FetchBlob("out_values"), - np.array([11.1, 14.1, 12.2, 13.2], dtype=np.float) + np.array([11.1, 14.1, 12.2, 13.2], dtype=np.float64) ) @@ -62,7 +62,7 @@ def test_merge_single_scalar_feature_tensors(self): # Input 1. workspace.FeedBlob( "in1", - np.array([11.1, 0.0], dtype=np.float) + np.array([11.1, 0.0], dtype=np.float64) ) workspace.FeedBlob( "in1_presence", @@ -71,7 +71,7 @@ def test_merge_single_scalar_feature_tensors(self): # Input 2. workspace.FeedBlob( "in2", - np.array([12.1, 12.2], dtype=np.float) + np.array([12.1, 12.2], dtype=np.float64) ) workspace.FeedBlob( "in2_presence", @@ -90,7 +90,7 @@ def test_merge_single_scalar_feature_tensors(self): ) np.testing.assert_array_equal( workspace.FetchBlob("out_values"), - np.array([11.1, 12.1, 12.2], dtype=np.float) + np.array([11.1, 12.1, 12.2], dtype=np.float64) ) def test_merge_single_scalar_feature_tensors_gradient(self): @@ -123,22 +123,22 @@ def test_merge_single_scalar_feature_tensors_gradient(self): # Input 4. workspace.FeedBlob( "out_values_grad", - np.array([0.1, 1.1, 1.2, 2.3], dtype=np.float) + np.array([0.1, 1.1, 1.2, 2.3], dtype=np.float64) ) workspace.RunOperatorOnce(op) np.testing.assert_array_equal( workspace.FetchBlob("in1_grad"), - np.array([0.1, 0], dtype=np.float) + np.array([0.1, 0], dtype=np.float64) ) np.testing.assert_array_equal( workspace.FetchBlob("in2_grad"), - np.array([1.1, 1.2], dtype=np.float) + np.array([1.1, 1.2], dtype=np.float64) ) np.testing.assert_array_equal( workspace.FetchBlob("in3_grad"), - np.array([0, 2.3], dtype=np.float) + np.array([0, 2.3], dtype=np.float64) ) def test_merge_single_scalar_feature_tensors_gradient_with_strings(self): @@ -210,7 +210,7 @@ def test_merge_single_list_feature_tensors(self): ) workspace.FeedBlob( "in1_values", - np.array([11.1, 11.2], dtype=np.float) + np.array([11.1, 11.2], dtype=np.float64) ) workspace.FeedBlob( "in1_presence", @@ -223,7 +223,7 @@ def test_merge_single_list_feature_tensors(self): ) workspace.FeedBlob( "in2_values", - np.array([12.1, 12.2, 12.3, 12.4], dtype=np.float) + np.array([12.1, 12.2, 12.3, 12.4], dtype=np.float64) ) workspace.FeedBlob( "in2_presence", @@ -246,7 +246,7 @@ def test_merge_single_list_feature_tensors(self): ) np.testing.assert_array_equal( workspace.FetchBlob("out_values_values"), - np.array([11.1, 11.2, 12.1, 12.2, 12.3, 12.4], dtype=np.float) + np.array([11.1, 11.2, 12.1, 12.2, 12.3, 12.4], dtype=np.float64) ) def test_merge_single_list_feature_tensors_gradient(self): @@ -293,18 +293,18 @@ def _test_merge_single_list_or_map_feature_tensors_gradient(self, op_name): ) workspace.FeedBlob( "out_values_values_grad", - np.array([11.1, 11.2, 12.1, 12.2, 12.3, 12.4], dtype=np.float) + np.array([11.1, 11.2, 12.1, 12.2, 12.3, 12.4], dtype=np.float64) ) workspace.RunOperatorOnce(op) np.testing.assert_array_equal( workspace.FetchBlob("in1_values_grad"), - np.array([11.1, 11.2], dtype=np.float) + np.array([11.1, 11.2], dtype=np.float64) ) np.testing.assert_array_equal( workspace.FetchBlob("in2_values_grad"), - np.array([12.1, 12.2, 12.3, 12.4], dtype=np.float) + np.array([12.1, 12.2, 12.3, 12.4], dtype=np.float64) ) def test_merge_single_map_feature_tensors(self): @@ -332,7 +332,7 @@ def test_merge_single_map_feature_tensors(self): ) workspace.FeedBlob( "in1_values", - np.array([11.1, 11.2], dtype=np.float) + np.array([11.1, 11.2], dtype=np.float64) ) workspace.FeedBlob( "in1_presence", @@ -349,7 +349,7 @@ def test_merge_single_map_feature_tensors(self): ) workspace.FeedBlob( "in2_values", - np.array([12.1, 12.2, 12.3, 12.4], dtype=np.float) + np.array([12.1, 12.2, 12.3, 12.4], dtype=np.float64) ) workspace.FeedBlob( "in2_presence", @@ -376,7 +376,7 @@ def test_merge_single_map_feature_tensors(self): ) np.testing.assert_array_equal( workspace.FetchBlob("out_values_values"), - np.array([11.1, 11.2, 12.1, 12.2, 12.3, 12.4], dtype=np.float) + np.array([11.1, 11.2, 12.1, 12.2, 12.3, 12.4], dtype=np.float64) ) def test_merge_multi_scalar_feature_tensors(self): @@ -402,7 +402,7 @@ def test_merge_multi_scalar_feature_tensors(self): ) workspace.FeedBlob( "in1_values", - np.array([11.0, 12.0, 13.0], dtype=np.float) + np.array([11.0, 12.0, 13.0], dtype=np.float64) ) # Input 2. workspace.FeedBlob( @@ -415,7 +415,7 @@ def test_merge_multi_scalar_feature_tensors(self): ) workspace.FeedBlob( "in2_values", - np.array([14.0, 15.0, 16.0], dtype=np.float) + np.array([14.0, 15.0, 16.0], dtype=np.float64) ) workspace.RunOperatorOnce(op) @@ -430,7 +430,7 @@ def test_merge_multi_scalar_feature_tensors(self): ) np.testing.assert_array_equal( workspace.FetchBlob("out_values"), - np.array([11.0, 14.0, 15.0, 12.0, 13.0, 16.0], dtype=np.float) + np.array([11.0, 14.0, 15.0, 12.0, 13.0, 16.0], dtype=np.float64) ) def test_merge_multi_scalar_feature_tensors_gradient(self): @@ -460,18 +460,18 @@ def test_merge_multi_scalar_feature_tensors_gradient(self): # Grad input. workspace.FeedBlob( "out_values_grad", - np.array([11.0, 14.0, 15.0, 12.0, 13.0, 16.0, 17.0], dtype=np.float) + np.array([11.0, 14.0, 15.0, 12.0, 13.0, 16.0, 17.0], dtype=np.float64) ) workspace.RunOperatorOnce(op) np.testing.assert_array_equal( workspace.FetchBlob("in1_values_grad"), - np.array([11.0, 12.0, 13.0], dtype=np.float) + np.array([11.0, 12.0, 13.0], dtype=np.float64) ) np.testing.assert_array_equal( workspace.FetchBlob("in2_values_grad"), - np.array([14.0, 15.0, 16.0, 17.0], dtype=np.float) + np.array([14.0, 15.0, 16.0, 17.0], dtype=np.float64) ) def test_merge_multi_list_feature_tensors(self): @@ -504,7 +504,7 @@ def test_merge_multi_list_feature_tensors(self): ) workspace.FeedBlob( "in1_values_values", - np.array([11.1, 11.2, 12.1, 12.2, 13.1, 13.2], dtype=np.float) + np.array([11.1, 11.2, 12.1, 12.2, 13.1, 13.2], dtype=np.float64) ) # Input 2. workspace.FeedBlob( @@ -521,7 +521,7 @@ def test_merge_multi_list_feature_tensors(self): ) workspace.FeedBlob( "in2_values_values", - np.array([14.1, 14.2, 15.1, 15.2, 16.1, 16.2], dtype=np.float) + np.array([14.1, 14.2, 15.1, 15.2, 16.1, 16.2], dtype=np.float64) ) workspace.RunOperatorOnce(op) @@ -545,7 +545,7 @@ def test_merge_multi_list_feature_tensors(self): 11.1, 11.2, 14.1, 14.2, 15.1, 15.2, 12.1, 12.2, 13.1, 13.2, 16.1, 16.2 ], - dtype=np.float + dtype=np.float64 ) ) @@ -583,7 +583,7 @@ def test_merge_multi_map_feature_tensors(self): ) workspace.FeedBlob( "in1_values_values", - np.array([11.1, 11.2, 12.1, 12.2, 13.1, 13.2], dtype=np.float) + np.array([11.1, 11.2, 12.1, 12.2, 13.1, 13.2], dtype=np.float64) ) # Input 2. workspace.FeedBlob( @@ -604,7 +604,7 @@ def test_merge_multi_map_feature_tensors(self): ) workspace.FeedBlob( "in2_values_values", - np.array([14.1, 14.2, 15.1, 15.2, 16.1, 16.2], dtype=np.float) + np.array([14.1, 14.2, 15.1, 15.2, 16.1, 16.2], dtype=np.float64) ) workspace.RunOperatorOnce(op) @@ -635,7 +635,7 @@ def test_merge_multi_map_feature_tensors(self): 11.1, 11.2, 14.1, 14.2, 15.1, 15.2, 12.1, 12.2, 13.1, 13.2, 16.1, 16.2 ], - dtype=np.float + dtype=np.float64 ) ) @@ -689,7 +689,7 @@ def _test_merge_multi_list_or_map_feature_tensors_gradient(self, op_name): 11.1, 11.2, 14.1, 14.2, 15.1, 15.2, 12.1, 12.2, 13.1, 13.2, 16.1, 16.2 ], - dtype=np.float + dtype=np.float64 ) ) @@ -697,9 +697,9 @@ def _test_merge_multi_list_or_map_feature_tensors_gradient(self, op_name): np.testing.assert_array_equal( workspace.FetchBlob("in1_values_values_grad"), - np.array([11.1, 11.2, 12.1, 12.2, 13.1, 13.2], dtype=np.float) + np.array([11.1, 11.2, 12.1, 12.2, 13.1, 13.2], dtype=np.float64) ) np.testing.assert_array_equal( workspace.FetchBlob("in2_values_values_grad"), - np.array([14.1, 14.2, 15.1, 15.2, 16.1, 16.2], dtype=np.float) + np.array([14.1, 14.2, 15.1, 15.2, 16.1, 16.2], dtype=np.float64) ) diff --git a/caffe2/python/operator_test/self_binning_histogram_test.py b/caffe2/python/operator_test/self_binning_histogram_test.py index f22a730e7e4acd..c4cd849f407fd4 100644 --- a/caffe2/python/operator_test/self_binning_histogram_test.py +++ b/caffe2/python/operator_test/self_binning_histogram_test.py @@ -147,7 +147,7 @@ def test_histogram_bin_to_two(self): def test_histogram_min_max_equal(self): """This test uses exact value match, so is only relevant for float type.""" X = np.array([0., 0., 0., 0., 0.], dtype='f') - logspacing_start = np.float(1e-24) + logspacing_start = np.float64(1e-24) self._run_single_op_net([X], 3, logspacing_start) if self.bin_spacing == "linear": self._check_histogram( diff --git a/caffe2/python/operator_test/stats_put_ops_test.py b/caffe2/python/operator_test/stats_put_ops_test.py index a15aec9f2271de..d145b39da60a3a 100644 --- a/caffe2/python/operator_test/stats_put_ops_test.py +++ b/caffe2/python/operator_test/stats_put_ops_test.py @@ -16,7 +16,7 @@ def test_default_value(self): count_postfix = "/stat_value/count".encode("ascii") default_value = 16.0 - workspace.FeedBlob("value", np.array([], dtype=np.float)) + workspace.FeedBlob("value", np.array([], dtype=np.float64)) workspace.RunOperatorOnce(core.CreateOperator( "AveragePut", @@ -48,7 +48,7 @@ def test_clamp(self): sum_postfix = "/stat_value/sum".encode("ascii") count_postfix = "/stat_value/count".encode("ascii") - workspace.FeedBlob("value", np.array([put_value], dtype=np.float)) + workspace.FeedBlob("value", np.array([put_value], dtype=np.float64)) workspace.RunOperatorOnce(core.CreateOperator( "AveragePut", @@ -79,7 +79,7 @@ def test_clamp_with_out_of_bounds(self): sum_postfix = "/stat_value/sum".encode("ascii") count_postfix = "/stat_value/count".encode("ascii") - workspace.FeedBlob("value", np.array([put_value], dtype=np.float)) + workspace.FeedBlob("value", np.array([put_value], dtype=np.float64)) workspace.RunOperatorOnce(core.CreateOperator( "AveragePut", @@ -110,7 +110,7 @@ def test_avg_put_ops(self): sum_postfix = "/stat_value/sum".encode("ascii") count_postfix = "/stat_value/count".encode("ascii") - workspace.FeedBlob("value", np.array([put_value], dtype=np.float)) + workspace.FeedBlob("value", np.array([put_value], dtype=np.float64)) workspace.RunOperatorOnce(core.CreateOperator( "AveragePut", @@ -139,7 +139,7 @@ def test_increment_put_ops(self): stat_name = "i1".encode('ascii') member_postfix = "/stat_value".encode("ascii") - workspace.FeedBlob("value", np.array([put_value], dtype=np.float)) + workspace.FeedBlob("value", np.array([put_value], dtype=np.float64)) workspace.RunOperatorOnce(core.CreateOperator( "IncrementPut", @@ -169,7 +169,7 @@ def test_stddev_put_ops(self): sumoffset_postfix = "/stat_value/sumoffset".encode("ascii") sumsqoffset_postfix = "/stat_value/sumsqoffset".encode("ascii") - workspace.FeedBlob("value", np.array([put_value], dtype=np.float)) + workspace.FeedBlob("value", np.array([put_value], dtype=np.float64)) workspace.RunOperatorOnce(core.CreateOperator( "StdDevPut", diff --git a/caffe2/python/sparse_to_dense_mask_test.py b/caffe2/python/sparse_to_dense_mask_test.py index cd4ccf43231d88..78202cc47ba4be 100644 --- a/caffe2/python/sparse_to_dense_mask_test.py +++ b/caffe2/python/sparse_to_dense_mask_test.py @@ -21,12 +21,12 @@ def test_sparse_to_dense_mask_float(self): np.array([2, 4, 6, 1, 2, 999999999, 2], dtype=np.int32)) workspace.FeedBlob( 'values', - np.array([1, 2, 3, 4, 5, 6, 7], dtype=np.float)) - workspace.FeedBlob('default', np.array(-1, dtype=np.float)) + np.array([1, 2, 3, 4, 5, 6, 7], dtype=np.float64)) + workspace.FeedBlob('default', np.array(-1, dtype=np.float64)) workspace.FeedBlob('lengths', np.array([3, 4], dtype=np.int32)) workspace.RunOperatorOnce(op) output = workspace.FetchBlob('output') - expected = np.array([[-1, 1, 3], [6, 7, -1]], dtype=np.float) + expected = np.array([[-1, 1, 3], [6, 7, -1]], dtype=np.float64) self.assertEqual(output.shape, expected.shape) np.testing.assert_array_equal(output, expected) @@ -42,8 +42,8 @@ def test_sparse_to_dense_mask_invalid_inputs(self): np.array([2000000000000, 999999999, 2, 3, 4, 5], dtype=np.int32)) workspace.FeedBlob( 'values', - np.array([1, 2, 3, 4, 5, 6], dtype=np.float)) - workspace.FeedBlob('default', np.array(-1, dtype=np.float)) + np.array([1, 2, 3, 4, 5, 6], dtype=np.float64)) + workspace.FeedBlob('default', np.array(-1, dtype=np.float64)) workspace.FeedBlob('lengths', np.array([6], dtype=np.int32)) try: workspace.RunOperatorOnce(op) @@ -69,14 +69,14 @@ def test_sparse_to_dense_mask_subtensor(self): workspace.FeedBlob( 'values', np.array([[[1, -1]], [[2, -2]], [[3, -3]], [[4, -4]], [[5, -5]]], - dtype=np.float)) - workspace.FeedBlob('default', np.array([[-1, 0]], dtype=np.float)) + dtype=np.float64)) + workspace.FeedBlob('default', np.array([[-1, 0]], dtype=np.float64)) workspace.FeedBlob('lengths', np.array([2, 3], dtype=np.int32)) workspace.RunOperatorOnce(op) output = workspace.FetchBlob('output') expected = np.array([ [[[-1, 0]], [[1, -1]], [[-1, 0]], [[-1, 0]]], - [[[4, -4]], [[5, -5]], [[-1, 0]], [[3, -3]]]], dtype=np.float) + [[[4, -4]], [[5, -5]], [[-1, 0]], [[3, -3]]]], dtype=np.float64) self.assertEqual(output.shape, expected.shape) np.testing.assert_array_equal(output, expected) @@ -108,11 +108,11 @@ def test_sparse_to_dense_mask_empty_lengths(self): ['output'], mask=[1, 2, 6]) workspace.FeedBlob('indices', np.array([2, 4, 6], dtype=np.int32)) - workspace.FeedBlob('values', np.array([1, 2, 3], dtype=np.float)) - workspace.FeedBlob('default', np.array(-1, dtype=np.float)) + workspace.FeedBlob('values', np.array([1, 2, 3], dtype=np.float64)) + workspace.FeedBlob('default', np.array(-1, dtype=np.float64)) workspace.RunOperatorOnce(op) output = workspace.FetchBlob('output') - expected = np.array([-1, 1, 3], dtype=np.float) + expected = np.array([-1, 1, 3], dtype=np.float64) self.assertEqual(output.shape, expected.shape) np.testing.assert_array_equal(output, expected) @@ -123,11 +123,11 @@ def test_sparse_to_dense_mask_no_lengths(self): ['output'], mask=[1, 2, 6]) workspace.FeedBlob('indices', np.array([2, 4, 6], dtype=np.int32)) - workspace.FeedBlob('values', np.array([1, 2, 3], dtype=np.float)) - workspace.FeedBlob('default', np.array(-1, dtype=np.float)) + workspace.FeedBlob('values', np.array([1, 2, 3], dtype=np.float64)) + workspace.FeedBlob('default', np.array(-1, dtype=np.float64)) workspace.RunOperatorOnce(op) output = workspace.FetchBlob('output') - expected = np.array([-1, 1, 3], dtype=np.float) + expected = np.array([-1, 1, 3], dtype=np.float64) self.assertEqual(output.shape, expected.shape) np.testing.assert_array_equal(output, expected) @@ -139,15 +139,15 @@ def test_sparse_to_dense_mask_presence_mask(self): mask=[11, 12], return_presence_mask=True) workspace.FeedBlob('indices', np.array([11, 12, 13], dtype=np.int32)) - workspace.FeedBlob('values', np.array([11, 12, 13], dtype=np.float)) - workspace.FeedBlob('default', np.array(-1, dtype=np.float)) + workspace.FeedBlob('values', np.array([11, 12, 13], dtype=np.float64)) + workspace.FeedBlob('default', np.array(-1, dtype=np.float64)) workspace.FeedBlob('lengths', np.array([1, 2], dtype=np.int32)) workspace.RunOperatorOnce(op) output = workspace.FetchBlob('output') presence_mask = workspace.FetchBlob('presence_mask') - expected_output = np.array([[11, -1], [-1, 12]], dtype=np.float) + expected_output = np.array([[11, -1], [-1, 12]], dtype=np.float64) expected_presence_mask = np.array( [[True, False], [False, True]], dtype=bool) diff --git a/functorch/examples/maml_omniglot/support/omniglot_loaders.py b/functorch/examples/maml_omniglot/support/omniglot_loaders.py index 8d7a95659a8b25..5d7f6421bbb43d 100644 --- a/functorch/examples/maml_omniglot/support/omniglot_loaders.py +++ b/functorch/examples/maml_omniglot/support/omniglot_loaders.py @@ -187,7 +187,7 @@ def __init__(self, root, batchsz, n_way, k_shot, k_query, imgsz, device=None): # as different class may have different number of imgs self.x = np.array(self.x).astype( - np.float + np.float64 ) # [[20 imgs],..., 1623 classes in total] # each character contains 20 imgs print("data shape:", self.x.shape) # [1623, 20, 84, 84, 1] diff --git a/test/dynamo/test_unspec.py b/test/dynamo/test_unspec.py index 9d0ec81a8cf690..e431db67a4a00d 100644 --- a/test/dynamo/test_unspec.py +++ b/test/dynamo/test_unspec.py @@ -251,7 +251,7 @@ def fn(image, scale_factor): @unittest.expectedFailure # fails as long as numpy scalars are 0D arrays def test_specializing_numpy_float_in_control_flow(self): - # np.float is unspecialized by default, + # np.float64 is unspecialized by default, # but it should be specialized when used in control flow. def fn(x, y): if y > 1.0: