@@ -33,20 +33,27 @@ class OpFlipOutTest : public ::testing::Test {
3333 // first.
3434 torch::executor::runtime_init ();
3535 }
36+
37+ template <ScalarType DTYPE>
38+ void test_1d_dtype () {
39+ TensorFactory<DTYPE> tf;
40+
41+ Tensor input =
42+ tf.make ({4 , 1 , 3 }, {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 });
43+ int64_t dims_data[1 ] = {-1 };
44+ IntArrayRef dims = IntArrayRef (dims_data, 1 );
45+ Tensor out = tf.zeros ({4 , 1 , 3 });
46+ Tensor out_expected =
47+ tf.make ({4 , 1 , 3 }, {3 , 2 , 1 , 6 , 5 , 4 , 9 , 8 , 7 , 12 , 11 , 10 });
48+ op_flip_out (input, dims, out);
49+ EXPECT_TENSOR_CLOSE (out, out_expected);
50+ }
3651};
3752
3853TEST_F (OpFlipOutTest, SmokeTest1Dim) {
39- TensorFactory<ScalarType::Float> tfFloat;
40-
41- Tensor input =
42- tfFloat.make ({4 , 1 , 3 }, {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 });
43- int64_t dims_data[1 ] = {-1 };
44- IntArrayRef dims = IntArrayRef (dims_data, 1 );
45- Tensor out = tfFloat.zeros ({4 , 1 , 3 });
46- Tensor out_expected =
47- tfFloat.make ({4 , 1 , 3 }, {3 , 2 , 1 , 6 , 5 , 4 , 9 , 8 , 7 , 12 , 11 , 10 });
48- op_flip_out (input, dims, out);
49- EXPECT_TENSOR_CLOSE (out, out_expected);
54+ #define TEST_ENTRY (ctype, dtype ) test_1d_dtype<ScalarType::dtype>();
55+ ET_FORALL_REALHBF16_TYPES (TEST_ENTRY);
56+ #undef TEST_ENTRY
5057}
5158
5259TEST_F (OpFlipOutTest, SmokeTest2Dims) {
0 commit comments