1 #include <gtest/gtest.h>
2
3 #include <torch/types.h>
4 #include <torch/utils.h>
5
6 using namespace at;
7
TEST(ReduceOpsTest,MaxValuesAndMinValues)8 TEST(ReduceOpsTest, MaxValuesAndMinValues) {
9 const int W = 10;
10 const int H = 10;
11 if (hasCUDA()) {
12 for (const auto dtype : {kHalf, kFloat, kDouble}) {
13 auto a = at::rand({H, W}, TensorOptions(kCUDA).dtype(dtype));
14 ASSERT_FLOAT_EQ(
15 a.amax(c10::IntArrayRef{0, 1}).item<double>(),
16 a.max().item<double>()
17 );
18 ASSERT_FLOAT_EQ(
19 a.amin(c10::IntArrayRef{0, 1}).item<double>(),
20 a.min().item<double>()
21 );
22 }
23 }
24 }
25