@@ -176,3 +176,34 @@ TEST_F(OpAnyOutTest, EmptyInput) {
176176 op_any_dims_out (x, dim_list, /* keepdim=*/ true , out);
177177 EXPECT_TENSOR_CLOSE (out, tfBool.make ({2 , 0 , 1 }, {}));
178178}
179+
180+ TEST_F (OpAnyOutTest, TestAnyDimsOutNullDimList) {
181+ TensorFactory<ScalarType::Int> tfInt;
182+ TensorFactory<ScalarType::Bool> tfBool;
183+
184+ Tensor self = tfInt.make ({2 , 6 }, {0 , 2 , 0 , 3 , 0 , 1 , 5 , 0 , 2 , 0 , 4 , 0 });
185+ optional<ArrayRef<int64_t >> opt_dim_list = std::nullopt ;
186+ bool keepdim = false ;
187+ Tensor out = tfBool.zeros ({});
188+ Tensor out_expected = tfBool.make ({}, {true });
189+
190+ op_any_dims_out (self, opt_dim_list, keepdim, out);
191+ EXPECT_TENSOR_CLOSE (out, out_expected);
192+ }
193+
194+ TEST_F (OpAnyOutTest, TestAnyDimsOutEmptyDimList) {
195+ TensorFactory<ScalarType::Int> tfInt;
196+ TensorFactory<ScalarType::Bool> tfBool;
197+
198+ Tensor self = tfInt.make ({2 , 3 }, {0 , 2 , 0 , 0 , 1 , 5 });
199+ int64_t dims[0 ] = {};
200+ size_t dims_size = 0 ;
201+ optional<ArrayRef<int64_t >> opt_dim_list{ArrayRef<int64_t >{dims, dims_size}};
202+ bool keepdim = false ;
203+ Tensor out = tfBool.zeros ({2 , 3 });
204+ Tensor out_expected =
205+ tfBool.make ({2 , 3 }, {false , true , false , false , true , true });
206+
207+ op_any_dims_out (self, opt_dim_list, keepdim, out);
208+ EXPECT_TENSOR_CLOSE (out, out_expected);
209+ }
0 commit comments