mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-15 21:00:47 +00:00
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
|
|
#include <gtest/gtest.h>
|
||
|
|
|
||
|
|
#include <c10/util/variant.h>
|
||
|
|
#include <torch/torch.h>
|
||
|
|
|
||
|
|
#include <test/cpp/api/support.h>
|
||
|
|
|
||
|
|
#define TORCH_ENUM_PRETTY_PRINT_TEST(name) \
|
||
|
|
{ \
|
||
|
|
v = torch::k##name; \
|
||
|
|
ASSERT_EQ(c10::visit(torch::enumtype::enum_name{}, v), #name); \
|
||
|
|
}
|
||
|
|
|
||
|
|
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,
|
||
|
|
torch::enumtype::kFanOut
|
||
|
|
> 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)
|
||
|
|
}
|