2019-10-17 05:39:22 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
|
|
#include <torch/torch.h>
|
|
|
|
|
|
|
|
|
|
#include <test/cpp/api/support.h>
|
|
|
|
|
|
|
|
|
|
#define TORCH_ENUM_PRETTY_PRINT_TEST(name) \
|
|
|
|
|
{ \
|
|
|
|
|
v = torch::k##name; \
|
2019-10-25 00:45:54 +00:00
|
|
|
std::string pretty_print_name("k"); \
|
|
|
|
|
pretty_print_name.append(#name); \
|
2019-10-29 21:13:37 +00:00
|
|
|
ASSERT_EQ(torch::enumtype::get_enum_name(v), pretty_print_name); \
|
2019-10-17 05:39:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(EnumTest, AllEnums) {
|
|
|
|
|
c10::variant<
|
|
|
|
|
torch::enumtype::kLinear,
|
|
|
|
|
torch::enumtype::kConv1D,
|
|
|
|
|
torch::enumtype::kConv2D,
|
|
|
|
|
torch::enumtype::kConv3D,
|
|
|
|
|
torch::enumtype::kConvTranspose1D,
|
|
|
|
|
torch::enumtype::kConvTranspose2D,
|
|
|
|
|
torch::enumtype::kConvTranspose3D,
|
|
|
|
|
torch::enumtype::kSigmoid,
|
|
|
|
|
torch::enumtype::kTanh,
|
|
|
|
|
torch::enumtype::kReLU,
|
|
|
|
|
torch::enumtype::kLeakyReLU,
|
|
|
|
|
torch::enumtype::kFanIn,
|
2019-10-22 05:16:21 +00:00
|
|
|
torch::enumtype::kFanOut,
|
|
|
|
|
torch::enumtype::kConstant,
|
|
|
|
|
torch::enumtype::kReflect,
|
|
|
|
|
torch::enumtype::kReplicate,
|
2019-10-25 00:45:54 +00:00
|
|
|
torch::enumtype::kCircular,
|
2019-10-29 04:32:30 +00:00
|
|
|
torch::enumtype::kNearest,
|
|
|
|
|
torch::enumtype::kBilinear,
|
|
|
|
|
torch::enumtype::kBicubic,
|
|
|
|
|
torch::enumtype::kTrilinear,
|
|
|
|
|
torch::enumtype::kArea,
|
2019-10-25 00:45:54 +00:00
|
|
|
torch::enumtype::kSum,
|
|
|
|
|
torch::enumtype::kMean,
|
2019-10-29 21:13:37 +00:00
|
|
|
torch::enumtype::kMax,
|
|
|
|
|
torch::enumtype::kNone,
|
|
|
|
|
torch::enumtype::kBatchMean
|
2019-10-17 05:39:22 +00:00
|
|
|
> v;
|
|
|
|
|
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Linear)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Conv1D)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Conv2D)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Conv3D)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(ConvTranspose1D)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(ConvTranspose2D)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(ConvTranspose3D)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Sigmoid)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Tanh)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(ReLU)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(LeakyReLU)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(FanIn)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(FanOut)
|
2019-10-22 05:16:21 +00:00
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Constant)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Reflect)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Replicate)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Circular)
|
2019-10-29 04:32:30 +00:00
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Nearest)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Bilinear)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Bicubic)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Trilinear)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Area)
|
2019-10-25 00:45:54 +00:00
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Sum)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Mean)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(Max)
|
2019-10-29 21:13:37 +00:00
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(None)
|
|
|
|
|
TORCH_ENUM_PRETTY_PRINT_TEST(BatchMean)
|
2019-10-17 05:39:22 +00:00
|
|
|
}
|