6 #include <ATen/core/interned_strings.h> 8 #include <torch/csrc/WindowsTorchApiMacro.h> 15 constexpr
int max_tensor_display_size = 10;
17 enum class AttributeKind { f, fs, i, is, s, ss, t, ts, g, gs };
18 static inline const char* toString(AttributeKind kind) {
19 static const char* names[] = {
20 "f",
"fs",
"i",
"is",
"s",
"ss",
"t",
"ts",
"g",
"gs"};
21 AT_ASSERT(
size_t(kind) <
sizeof(names) /
sizeof(AttributeKind));
22 return names[int(kind)];
27 using Ptr = std::unique_ptr<AttributeValue>;
29 virtual AttributeKind kind()
const = 0;
30 virtual Ptr clone()
const = 0;
34 template <
typename T, AttributeKind Kind>
43 Ptr clone()
const override {
46 AttributeKind kind()
const override {
54 template <
typename T, AttributeKind Kind>
56 using ConstructorType = std::vector<T>;
57 using ValueType = std::vector<T>;
63 AttributeKind kind()
const override {
66 std::unique_ptr<AttributeValue> clone()
const override {
88 using ConstructorType = std::shared_ptr<Graph>;
89 using ValueType = std::shared_ptr<Graph>;
95 TORCH_API Ptr clone()
const override;
96 AttributeKind kind()
const override {
97 return AttributeKind::g;
101 std::shared_ptr<Graph> value_;
105 using ConstructorType = std::vector<std::shared_ptr<Graph>>;
106 using ValueType = std::vector<std::shared_ptr<Graph>>;
112 AttributeKind kind()
const override {
113 return AttributeKind::gs;
115 TORCH_API std::unique_ptr<AttributeValue> clone()
const override;
123 std::stringstream ss;
125 ss <<
"required keyword attribute '" << name.toUnqualString()
126 <<
"' is undefined.";
128 ss <<
"required keyword attribute '" << name.toUnqualString()
129 <<
"' has the wrong type";
133 const char* what()
const noexcept
override {