forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema_type_parser.h
41 lines (34 loc) · 1.09 KB
/
schema_type_parser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <ATen/core/alias_info.h>
#include <ATen/core/jit_type.h>
#include <c10/macros/Macros.h>
#include <c10/util/FunctionRef.h>
#include <torch/csrc/jit/frontend/lexer.h>
namespace torch {
namespace jit {
using TypePtr = c10::TypePtr;
struct TORCH_API SchemaTypeParser {
TypePtr parseBaseType();
c10::optional<c10::AliasInfo> parseAliasAnnotation();
std::pair<TypePtr, c10::optional<c10::AliasInfo>> parseType();
std::tuple</*fake*/ TypePtr, /*real*/ TypePtr, c10::optional<c10::AliasInfo>>
parseFakeAndRealType();
c10::optional<at::ScalarType> parseTensorDType(const std::string& dtype);
TypePtr parseRefinedTensor();
SchemaTypeParser(Lexer& L, bool parse_complete_tensor_types) : L(L) {
complete_tensor_types = parse_complete_tensor_types;
}
private:
c10::optional<bool> tryToParseRequiresGrad();
c10::optional<c10::Device> tryToParseDeviceType();
void parseList(
int begin,
int sep,
int end,
c10::function_ref<void()> callback);
bool complete_tensor_types;
Lexer& L;
size_t next_id = 0;
};
} // namespace jit
} // namespace torch