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