mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
29 lines
645 B
C++
29 lines
645 B
C++
#include "torch/csrc/jit/script/lexer.h"
|
|
#include <string>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
namespace script {
|
|
|
|
std::string kindToString(int kind) {
|
|
if (kind < 256)
|
|
return std::string(1, kind);
|
|
switch (kind) {
|
|
#define DEFINE_CASE(tok, str, _) \
|
|
case tok: \
|
|
return str;
|
|
TC_FORALL_TOKEN_KINDS(DEFINE_CASE)
|
|
#undef DEFINE_CASE
|
|
default:
|
|
throw std::runtime_error("Unknown kind: " + std::to_string(kind));
|
|
}
|
|
}
|
|
|
|
SharedParserData& sharedParserData() {
|
|
static SharedParserData data; // safely handles multi-threaded init
|
|
return data;
|
|
}
|
|
} // namespace script
|
|
} // namespace jit
|
|
} // namespace torch
|