提交 0d165399 编写于 作者: M Megvii Engine Team

fix(mgb): fix fastrun for imperative

GitOrigin-RevId: db54984b92623a406b15472111fccb0ea07575d3
上级 94401ce4
...@@ -172,7 +172,10 @@ public: ...@@ -172,7 +172,10 @@ public:
template <typename T> template <typename T>
static void serialize_write_pod(const T& val, std::string& result) { static void serialize_write_pod(const T& val, std::string& result) {
static_assert(std::is_standard_layout<T>::value, "invalid type"); static_assert(std::is_trivially_copyable<T>::value,
"type should be trivially copyable");
static_assert(!std::is_pointer<T>::value,
"serialize pointer is unsafe in eager execution mode");
result.append(reinterpret_cast<const char*>(&val), sizeof(T)); result.append(reinterpret_cast<const char*>(&val), sizeof(T));
} }
...@@ -182,7 +185,7 @@ public: ...@@ -182,7 +185,7 @@ public:
template <typename T> template <typename T>
static T deserialize_read_pod(const std::string& data, size_t offset = 0) { static T deserialize_read_pod(const std::string& data, size_t offset = 0) {
static_assert(std::is_standard_layout<T>::value, "invalid type"); static_assert(std::is_trivially_copyable<T>::value, "invalid type");
T ret; T ret;
//! A pointer to an object or incomplete type may be converted to a //! A pointer to an object or incomplete type may be converted to a
//! pointer to a different object or incomplete type. If the resulting //! pointer to a different object or incomplete type. If the resulting
...@@ -197,7 +200,7 @@ public: ...@@ -197,7 +200,7 @@ public:
template <typename T> template <typename T>
static T deserialize_read_pod(const char* data, size_t offset = 0) { static T deserialize_read_pod(const char* data, size_t offset = 0) {
static_assert(std::is_standard_layout<T>::value, "invalid type"); static_assert(std::is_trivially_copyable<T>::value, "invalid type");
T ret; T ret;
//! A pointer to an object or incomplete type may be converted to a //! A pointer to an object or incomplete type may be converted to a
//! pointer to a different object or incomplete type. If the resulting //! pointer to a different object or incomplete type. If the resulting
......
...@@ -439,7 +439,7 @@ public: ...@@ -439,7 +439,7 @@ public:
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_impl, ret); serialize_write_pod(m_impl->name(), ret);
return ret; return ret;
} }
......
...@@ -238,7 +238,7 @@ public: ...@@ -238,7 +238,7 @@ public:
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_impl, ret); serialize_write_pod(m_impl->name(), ret);
return ret; return ret;
} }
}; };
......
...@@ -223,7 +223,7 @@ public: ...@@ -223,7 +223,7 @@ public:
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_impl, ret); serialize_write_pod(m_impl->name(), ret);
return ret; return ret;
} }
}; };
......
...@@ -174,7 +174,7 @@ public: ...@@ -174,7 +174,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(CUDA_GROUP_CONV_GENERAL) MEGDNN_DECL_ALGO_TYPE(CUDA_GROUP_CONV_GENERAL)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_impl, ret); serialize_write_pod(m_impl->name(), ret);
return ret; return ret;
} }
}; };
......
...@@ -183,7 +183,7 @@ public: ...@@ -183,7 +183,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(CUDA_GROUP_CONV_GENERAL) MEGDNN_DECL_ALGO_TYPE(CUDA_GROUP_CONV_GENERAL)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_impl, ret); serialize_write_pod(m_impl->name(), ret);
return ret; return ret;
} }
}; };
......
...@@ -135,7 +135,7 @@ public: ...@@ -135,7 +135,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(CUDA_GROUP_CONV_GENERAL) MEGDNN_DECL_ALGO_TYPE(CUDA_GROUP_CONV_GENERAL)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_impl, ret); serialize_write_pod(m_impl->name(), ret);
return ret; return ret;
} }
}; };
......
...@@ -67,7 +67,7 @@ public: ...@@ -67,7 +67,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_F32) MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_F32)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_matmul_algo, ret); serialize_write_pod(m_matmul_algo->name(), ret);
return ret; return ret;
} }
...@@ -103,7 +103,7 @@ public: ...@@ -103,7 +103,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_4X4_F32) MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_4X4_F32)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_matmul_algo, ret); serialize_write_pod(m_matmul_algo->name(), ret);
return ret; return ret;
} }
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_QS8) MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_QS8)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_matmul_algo, ret); serialize_write_pod(m_matmul_algo->name(), ret);
return ret; return ret;
} }
...@@ -175,7 +175,7 @@ public: ...@@ -175,7 +175,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_8X8_QS8) MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_8X8_QS8)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_matmul_algo, ret); serialize_write_pod(m_matmul_algo->name(), ret);
return ret; return ret;
} }
......
...@@ -157,7 +157,7 @@ using BiasMode = ConvBiasForward::BiasMode; ...@@ -157,7 +157,7 @@ using BiasMode = ConvBiasForward::BiasMode;
} \ } \
std::string param() const override { \ std::string param() const override { \
std::string ret; \ std::string ret; \
serialize_write_pod(m_matmul_algo, ret); \ serialize_write_pod(m_matmul_algo->name(), ret); \
serialize_write_pod(m_tile_size, ret); \ serialize_write_pod(m_tile_size, ret); \
return ret; \ return ret; \
} \ } \
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_8X8_QS8) MEGDNN_DECL_ALGO_TYPE(FB_WINOGRAD_8X8_QS8)
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_matmul_algo, ret); serialize_write_pod(m_matmul_algo->name(), ret);
serialize_write_pod(m_oc_block_size, ret); serialize_write_pod(m_oc_block_size, ret);
return ret; return ret;
} }
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_matmul_algo, ret); serialize_write_pod(m_matmul_algo->name(), ret);
serialize_write_pod(m_ohw_tile_size, ret); serialize_write_pod(m_ohw_tile_size, ret);
return ret; return ret;
} }
......
...@@ -157,7 +157,7 @@ public: ...@@ -157,7 +157,7 @@ public:
std::string param() const override { std::string param() const override {
std::string ret; std::string ret;
serialize_write_pod(m_algorithm, ret); serialize_write_pod(m_algorithm->name(), ret);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册