Caffe2 - C++ API
A deep learning, cross platform ML framework
register_symbols.cpp
1 #include <ATen/core/interned_strings_class.h>
2 
3 namespace c10 {
4 
5 namespace {
6 
7 struct Entry {
8  const char* const qual_name;
9  const char* const unqual_name;
10  const Symbol sym;
11  const Symbol ns_sym;
12 };
13 
14 constexpr Entry entries[] = {
15 #define SYMBOL_ENTRY(n, s) {#n "::" #s, #s, n::s, namespaces::n},
16 
17  FORALL_NS_SYMBOLS(SYMBOL_ENTRY)
18 #undef SYMBOL_ENTRY
19 };
20 
21 } // namespace
22 
23 InternedStrings::InternedStrings()
24  : sym_to_info_(static_cast<size_t>(_keys::num_symbols)) {
25  // Instead of a loop, this could be done by expanding the
26  // assignments directly into FORALL_NS_SYMBOLS, but it would create
27  // a huge function (thanks to all the std::string constructors and
28  // operator[]s) which would take several minutes to optimize. A
29  // static C array of constexpr-constructible structs takes instead
30  // no time to compile.
31  for (const auto& entry : entries) {
32  string_to_sym_[entry.qual_name] = entry.sym;
33  sym_to_info_[entry.sym] = {
34  entry.ns_sym, entry.qual_name, entry.unqual_name};
35  }
36 }
37 
38 } // namespace c10
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...
Definition: alias_info.h:7