From a66c930c982c60e33faf141e77d2a3793594fb0f Mon Sep 17 00:00:00 2001 From: kentado <8176770+kentado@user.noreply.gitee.com> Date: Fri, 16 Apr 2021 19:03:48 +0800 Subject: [PATCH] add test_mindspore.cc. --- test_mindspore.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test_mindspore.cc diff --git a/test_mindspore.cc b/test_mindspore.cc new file mode 100644 index 00000000..3980c678 --- /dev/null +++ b/test_mindspore.cc @@ -0,0 +1,18 @@ +namespace mindspore { +const bool Base::IsFromTypeId(uint32_t tid) const { + static const uint32_t node_id = GetTypeId(typeid(Base).name()); + return tid == node_id; +} + +uint32_t Base::GetTypeId(const char *const type_name) { + TypeIdManager *t = TypeIdManager::Get(); + std::lock_guard(t->mutex); + auto it = t->map.find(type_name); + if (it != t->map.end()) { + return it->second; + } + uint32_t tid = ++(t->type_counter); + t->map[type_name] = tid; + return tid; +} +} // namespace mindspore \ No newline at end of file -- Gitee