GitOrigin-RevId: aa27ecbf21
release-0.6
@@ -48,6 +48,13 @@ namespace mgb { | |||||
//! warn if result of a function is not used | //! warn if result of a function is not used | ||||
#define MGB_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | #define MGB_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) | ||||
#if __cplusplus >= 201703L || __clang_major__ >= 4 | |||||
#define MGB_FALLTHRU [[fallthrough]]; | |||||
#elif __GNUC__ >= 7 | |||||
#define MGB_FALLTHRU __attribute__((fallthrough)); | |||||
#else | |||||
#define MGB_FALLTHRU | |||||
#endif | |||||
/* ================ exception and assertion ================ */ | /* ================ exception and assertion ================ */ | ||||
@@ -53,10 +53,11 @@ bool GraphDumper::should_remove_in_dump(cg::OperatorNodeBase *opr) { | |||||
std::unique_ptr<GraphDumper> GraphDumper::make(std::unique_ptr<OutputFile> file, | std::unique_ptr<GraphDumper> GraphDumper::make(std::unique_ptr<OutputFile> file, | ||||
GraphDumpFormat format) { | GraphDumpFormat format) { | ||||
switch (format) { | switch (format) { | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
case GraphDumpFormat::FLATBUFFERS: | case GraphDumpFormat::FLATBUFFERS: | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
return make_fbs_dumper(std::move(file)); | return make_fbs_dumper(std::move(file)); | ||||
#endif | #endif | ||||
MGB_FALLTHRU | |||||
default: | default: | ||||
mgb_throw(SerializationError, | mgb_throw(SerializationError, | ||||
"unsupported serialization format requested"); | "unsupported serialization format requested"); | ||||
@@ -66,10 +67,11 @@ std::unique_ptr<GraphDumper> GraphDumper::make(std::unique_ptr<OutputFile> file, | |||||
std::unique_ptr<GraphLoader> GraphLoader::make(std::unique_ptr<InputFile> file, GraphDumpFormat format) { | std::unique_ptr<GraphLoader> GraphLoader::make(std::unique_ptr<InputFile> file, GraphDumpFormat format) { | ||||
switch (format) { | switch (format) { | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
case GraphDumpFormat::FLATBUFFERS: | case GraphDumpFormat::FLATBUFFERS: | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
return make_fbs_loader(std::move(file)); | return make_fbs_loader(std::move(file)); | ||||
#endif | #endif | ||||
MGB_FALLTHRU | |||||
default: | default: | ||||
mgb_throw(SerializationError, | mgb_throw(SerializationError, | ||||
"unsupported serialization format requested"); | "unsupported serialization format requested"); | ||||
@@ -29,9 +29,7 @@ struct OperatorParamTraits; | |||||
enum class SerializationFormat { | enum class SerializationFormat { | ||||
RAW_POD, | RAW_POD, | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
FLATBUFFERS, | FLATBUFFERS, | ||||
#endif | |||||
}; | }; | ||||
//! context for serializing a single operator | //! context for serializing a single operator | ||||
@@ -162,12 +160,12 @@ void OprDumpContext::write_param(const Param& p) { | |||||
case SerializationFormat::RAW_POD: | case SerializationFormat::RAW_POD: | ||||
static_cast<OprDumpContextRawPOD*>(this)->write_param(p); | static_cast<OprDumpContextRawPOD*>(this)->write_param(p); | ||||
break; | break; | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
case SerializationFormat::FLATBUFFERS: | case SerializationFormat::FLATBUFFERS: | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
static_cast<OprDumpContextFlatBuffers*>(this)->write_param( | static_cast<OprDumpContextFlatBuffers*>(this)->write_param( | ||||
p, fbs::SupportFlatBuffersSerialization<Param>{}); | p, fbs::SupportFlatBuffersSerialization<Param>{}); | ||||
break; | |||||
#endif | #endif | ||||
break; | |||||
} | } | ||||
} | } | ||||
@@ -322,11 +320,13 @@ Param OprLoadContext::read_param() { | |||||
case SerializationFormat::RAW_POD: | case SerializationFormat::RAW_POD: | ||||
return static_cast<OprLoadContextRawPOD*>(this) | return static_cast<OprLoadContextRawPOD*>(this) | ||||
->read_param<Param>(); | ->read_param<Param>(); | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
case SerializationFormat::FLATBUFFERS: | case SerializationFormat::FLATBUFFERS: | ||||
#if MGB_ENABLE_FBS_SERIALIZATION | |||||
return static_cast<OprLoadContextFlatBuffers*>(this) | return static_cast<OprLoadContextFlatBuffers*>(this) | ||||
->read_param<Param>( | ->read_param<Param>( | ||||
fbs::SupportFlatBuffersSerialization<Param>{}); | fbs::SupportFlatBuffersSerialization<Param>{}); | ||||
#else | |||||
mgb_trap(); | |||||
#endif | #endif | ||||
} | } | ||||
mgb_assert(0); | mgb_assert(0); | ||||