serialize.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <string>
8 
9 #include "ngraph/opsets/opset.hpp"
10 #include "ngraph/pass/pass.hpp"
11 #include "transformations_visibility.hpp"
12 
13 namespace ngraph {
14 namespace pass {
15 
16 class TRANSFORMATIONS_API Serialize;
17 
18 } // namespace pass
19 } // namespace ngraph
20 
21 /**
22  * @ingroup ie_transformation_common_api
23  * @brief Serialize transformation converts ngraph::Function into IR files
24  * @attention
25  * - dynamic shapes are not supported
26  * - order of generated layers in xml file is ngraph specific (given by
27  * get_ordered_ops()); MO generates file with different order, but they are
28  * logically equivalent
29  */
30 class ngraph::pass::Serialize : public ngraph::pass::FunctionPass {
31 public:
32  enum class Version { IR_V10 };
33  NGRAPH_RTTI_DECLARATION;
34  bool run_on_function(std::shared_ptr<ngraph::Function> f) override;
35 
36  Serialize(std::ostream & xmlFile, std::ostream & binFile,
37  Version version = Version::IR_V10,
38  std::map<std::string, ngraph::OpSet> custom_opsets = {});
39 
40  Serialize(const std::string& xmlPath, const std::string& binPath,
41  Version version = Version::IR_V10,
42  std::map<std::string, ngraph::OpSet> custom_opsets = {});
43 
44 private:
45  std::ostream * m_xmlFile;
46  std::ostream * m_binFile;
47  const std::string m_xmlPath;
48  const std::string m_binPath;
49  const Version m_version;
50  const std::map<std::string, ngraph::OpSet> m_custom_opsets;
51 };
Serialize transformation converts ngraph::Function into IR files.
Definition: serialize.hpp:30
ngraph namespace
Definition: add_fake_quantize_fusion.hpp:14