@@ -38,12 +38,25 @@ class OpFullOutTest : public OperatorTest {
38
38
std::vector<int64_t > size_int64_t (size_int32_t .begin (), size_int32_t .end ());
39
39
auto aref = IntArrayRef (size_int64_t .data (), size_int64_t .size ());
40
40
41
+ // Boolean Scalar
41
42
// Before: `out` consists of 0s.
42
43
Tensor out = tf.zeros (size_int32_t );
44
+ // After: `out` consists of 1s.
45
+ op_full_out (aref, true , out);
46
+ EXPECT_TENSOR_EQ (out, tf.ones (size_int32_t ));
43
47
48
+ // Integral Scalar
49
+ // Before: `out` consists of 0s.
50
+ out = tf.zeros (size_int32_t );
44
51
// After: `out` consists of 1s.
45
52
op_full_out (aref, 1 , out);
53
+ EXPECT_TENSOR_EQ (out, tf.ones (size_int32_t ));
46
54
55
+ // Floating Point Scalar
56
+ // Before: `out` consists of 0s.
57
+ out = tf.zeros (size_int32_t );
58
+ // After: `out` consists of 1s.
59
+ op_full_out (aref, 1.0 , out);
47
60
EXPECT_TENSOR_EQ (out, tf.ones (size_int32_t ));
48
61
}
49
62
};
@@ -57,4 +70,55 @@ class OpFullOutTest : public OperatorTest {
57
70
test_ones_out<ScalarType::DTYPE>({2 , 3 , 4 }); \
58
71
}
59
72
60
- ET_FORALL_REAL_TYPES (GENERATE_TEST)
73
+ ET_FORALL_REALH_TYPES (GENERATE_TEST)
74
+
75
+ TEST_F(OpFullOutTest, ValueOverflow) {
76
+ if (torch::executor::testing::SupportedFeatures::get ()->is_aten ) {
77
+ GTEST_SKIP () << " ATen kernel doesn't handle overflow" ;
78
+ }
79
+ TensorFactory<ScalarType::Byte> tf;
80
+
81
+ std::vector<int64_t > sizes_int64_t_vec = {2 , 3 };
82
+ std::vector<int32_t > sizes_in32_t_vec = {2 , 3 };
83
+ auto sizes = IntArrayRef (sizes_int64_t_vec.data (), sizes_int64_t_vec.size ());
84
+
85
+ Tensor out = tf.zeros (sizes_in32_t_vec);
86
+
87
+ op_full_out (sizes, 1000 , out);
88
+ }
89
+
90
+ TEST_F (OpFullOutTest, HalfSupport) {
91
+ TensorFactory<ScalarType::Half> tf;
92
+
93
+ std::vector<int64_t > sizes_int64_t_vec = {2 , 3 };
94
+ std::vector<int32_t > sizes_in32_t_vec = {2 , 3 };
95
+ auto sizes = IntArrayRef (sizes_int64_t_vec.data (), sizes_int64_t_vec.size ());
96
+
97
+ // Boolean Scalar
98
+ Tensor out = tf.zeros (sizes_in32_t_vec);
99
+ op_full_out (sizes, true , out);
100
+ EXPECT_TENSOR_EQ (out, tf.ones (sizes_in32_t_vec));
101
+
102
+ // Integral Scalar
103
+ out = tf.zeros (sizes_in32_t_vec);
104
+ op_full_out (sizes, 1 , out);
105
+ EXPECT_TENSOR_EQ (out, tf.ones (sizes_in32_t_vec));
106
+
107
+ // Floating Point Scalar
108
+ out = tf.zeros (sizes_in32_t_vec);
109
+ op_full_out (sizes, 3.1415926535 , out);
110
+ EXPECT_TENSOR_EQ (out, tf.full (sizes_in32_t_vec, 3.1415926535 ));
111
+ }
112
+
113
+ TEST_F (OpFullOutTest, ZeroDim) {
114
+ TensorFactory<ScalarType::Half> tf;
115
+
116
+ std::vector<int64_t > sizes_int64_t_vec = {};
117
+ std::vector<int32_t > sizes_in32_t_vec = {};
118
+ auto sizes = IntArrayRef (sizes_int64_t_vec.data (), sizes_int64_t_vec.size ());
119
+
120
+ // Boolean Scalar
121
+ Tensor out = tf.zeros (sizes_in32_t_vec);
122
+ op_full_out (sizes, true , out);
123
+ EXPECT_TENSOR_EQ (out, tf.ones (sizes_in32_t_vec));
124
+ }
0 commit comments