From 1e3af4dd173c998f8701c4199d67336f8ae33b3b Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Mon, 16 Aug 2021 14:12:34 +0800 Subject: [PATCH] fix(mgb/comp_node): add more info in `comp_node.to_string()` GitOrigin-RevId: 794a8847aa9900a8362537f589f99f3da47755f1 --- imperative/python/src/common.cpp | 4 +++- lite/.gitattributes | 10 ---------- src/core/include/megbrain/comp_node.h | 9 ++++++++- 3 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 lite/.gitattributes diff --git a/imperative/python/src/common.cpp b/imperative/python/src/common.cpp index f91eb9b8e..96d64b9e6 100644 --- a/imperative/python/src/common.cpp +++ b/imperative/python/src/common.cpp @@ -66,7 +66,9 @@ void init_common(py::module m) { .def_static("_get_default_device", &get_default_device) .def("__str__", &CompNode::to_string_logical) .def("__repr__", [](const CompNode& cn) { - return py::str("\"" + cn.to_string() + "\" from \"" + cn.to_string_logical() + "\""); + return mgb::ssprintf("CompNode(\"%s\" from \"%s\")", + cn.to_string_physical().c_str(), + cn.to_string_logical().c_str()); }) .def_static("_sync_all", &CompNode::sync_all) .def(py::self == py::self) diff --git a/lite/.gitattributes b/lite/.gitattributes deleted file mode 100644 index c268a9ab6..000000000 --- a/lite/.gitattributes +++ /dev/null @@ -1,10 +0,0 @@ -test/resource/input_data.npy filter=lfs diff=lfs merge=lfs -text -test/resource/lite/shufflenet.mge filter=lfs diff=lfs merge=lfs -text -test/resource/lite/shufflenet_crypt_aes.mge filter=lfs diff=lfs merge=lfs -text -test/resource/lite/test_packed_model.lite filter=lfs diff=lfs merge=lfs -text -test/resource/lite/test_packed_model_rc4.lite filter=lfs diff=lfs merge=lfs -text -test/resource/lite/output_data.npy filter=lfs diff=lfs merge=lfs -text -test/resource/lite/model.mgb filter=lfs diff=lfs merge=lfs -text -test/resource/lite/liveness_rgb_nosub128.rknn filter=lfs diff=lfs merge=lfs -text -third_party/librknn_api filter=lfs diff=lfs merge=lfs -text -test/resource/lite/model_atlas.mgb filter=lfs diff=lfs merge=lfs -text diff --git a/src/core/include/megbrain/comp_node.h b/src/core/include/megbrain/comp_node.h index 87c362ed0..d03a3efd1 100644 --- a/src/core/include/megbrain/comp_node.h +++ b/src/core/include/megbrain/comp_node.h @@ -368,8 +368,15 @@ class CompNode { //! change to another stream on the same memory node CompNode change_stream(int dest_stream) const; - //! get string representation of physical device + //! get string representation std::string to_string() const { + return m_impl ? mgb::ssprintf("CompNode(\"%s\" from \"%s\")", + to_string_physical().c_str(), + to_string_logical().c_str()) : "invalid"; + } + + //! get string representation of physical device + std::string to_string_physical() const { return m_impl ? m_impl->locator().to_string() : "invalid"; } -- GitLab