target_info.cc 850 Bytes
Newer Older
1 2 3 4 5
/*!
 *  Copyright (c) 2017 by Contributors
 * \file target_info.cc
 */
#include <tvm/target_info.h>
6
#include <tvm/packed_func_ext.h>
7 8 9 10 11 12 13 14

namespace tvm {

TVM_STATIC_IR_FUNCTOR(IRPrinter, vtable)
.set_dispatch<MemoryInfoNode>([](const MemoryInfoNode *op, IRPrinter *p) {
    p->stream << "mem-info("
              << "unit_bits=" << op->unit_bits << ", "
              << "max_num_bits=" << op->max_num_bits << ", "
15 16
              << "max_simd_bits=" << op->max_simd_bits << ", "
              << "head_address=" << op->head_address << ")";
17 18 19 20
});

TVM_REGISTER_NODE_TYPE(MemoryInfoNode);

21 22 23 24 25 26 27 28 29 30
MemoryInfo GetMemoryInfo(const std::string& scope) {
  std::string fname = "tvm.info.mem." + scope;
  const runtime::PackedFunc* f = runtime::Registry::Get(fname);
  if (f == nullptr) {
    return MemoryInfo();
  } else {
    return (*f)();
  }
}

31
}  // namespace tvm