@@ -218,6 +218,64 @@ EXPECT_TENSOR_EQ(min_indices, tf_long.make(
218218 // clang-format on
219219}
220220
221+ class OpMinUnaryOutTest : public OperatorTest {
222+ protected:
223+ Tensor& op_min_unary_out (const Tensor& self, Tensor& out) {
224+ return torch::executor::aten::min_outf (context_, self, out);
225+ }
226+
227+ template <ScalarType IN_DTYPE>
228+ void test_min_unary_out_dtype () {
229+ TensorFactory<IN_DTYPE> tf_in;
230+ TensorFactory<ScalarType::Float> tf_out;
231+ Tensor input = tf_in.make ({2 , 3 }, {7 , 1 , 3 , 4 , 4 , 2 });
232+ Tensor out = tf_out.zeros ({});
233+ Tensor expected = tf_out.make ({}, {1 });
234+ op_min_unary_out (input, out);
235+ EXPECT_TENSOR_CLOSE (out, expected);
236+ }
237+
238+ template <typename CTYPE, ScalarType IN_DTYPE>
239+ void test_min_unary_out_empty_integer () {
240+ TensorFactory<IN_DTYPE> tf_in;
241+ Tensor input = tf_in.make ({2 , 0 }, {});
242+ Tensor out = tf_in.zeros ({});
243+ Tensor expected = tf_in.make ({}, {std::numeric_limits<CTYPE>::max ()});
244+ op_min_unary_out (input, out);
245+ EXPECT_TENSOR_CLOSE (out, expected);
246+ }
247+
248+ template <typename CTYPE, ScalarType IN_DTYPE>
249+ void test_min_unary_out_empty_floating () {
250+ TensorFactory<IN_DTYPE> tf_in;
251+ Tensor input = tf_in.make ({2 , 0 }, {});
252+ Tensor out = tf_in.zeros ({});
253+ Tensor expected = tf_in.make ({}, {INFINITY});
254+ op_min_unary_out (input, out);
255+ EXPECT_TENSOR_CLOSE (out, expected);
256+ }
257+ };
258+
259+ TEST_F (OpMinUnaryOutTest, AllRealHBF16InputFloatOutputPasses) {
260+ #define TEST_ENTRY (ctype, dtype ) test_min_unary_out_dtype<ScalarType::dtype>();
261+ ET_FORALL_REALHBF16_TYPES (TEST_ENTRY);
262+ #undef TEST_ENTRY
263+ }
264+
265+ TEST_F (OpMinUnaryOutTest, EmptyIntegerInput) {
266+ #define TEST_ENTRY (ctype, dtype ) \
267+ test_min_unary_out_empty_integer<ctype, ScalarType::dtype>();
268+ ET_FORALL_INT_TYPES (TEST_ENTRY);
269+ #undef TEST_ENTRY
270+ }
271+
272+ TEST_F (OpMinUnaryOutTest, EmptyFloatingInput) {
273+ #define TEST_ENTRY (ctype, dtype ) \
274+ test_min_unary_out_empty_floating<ctype, ScalarType::dtype>();
275+ ET_FORALL_FLOATHBF16_TYPES (TEST_ENTRY);
276+ #undef TEST_ENTRY
277+ }
278+
221279TEST_F (OpMinOutTest, MismatchedDimensionsDies) {
222280 if (torch::executor::testing::SupportedFeatures::get ()->is_aten ) {
223281 GTEST_SKIP () << " ATen kernel test fails" ;
0 commit comments