Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/onnx/common/ir_pb_converter.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (c) ONNX Project Contributors
0002 
0003 /*
0004  * SPDX-License-Identifier: Apache-2.0
0005  */
0006 
0007 // ATTENTION: The code in this file is highly EXPERIMENTAL.
0008 // Adventurous users should note that the APIs will probably change.
0009 
0010 #pragma once
0011 #include <memory>
0012 #include <string>
0013 
0014 #include "onnx/common/common.h"
0015 #include "onnx/common/ir.h"
0016 #include "onnx/onnx_pb.h"
0017 
0018 namespace ONNX_NAMESPACE {
0019 
0020 class ConvertError final : public std::runtime_error {
0021  public:
0022   using std::runtime_error::runtime_error;
0023 
0024   explicit ConvertError(const std::string& message) : std::runtime_error(message) {}
0025 
0026   const char* what() const noexcept override {
0027     if (!expanded_message_.empty()) {
0028       return expanded_message_.c_str();
0029     }
0030     return std::runtime_error::what();
0031   }
0032 
0033   void AppendContext(const std::string& context) {
0034     expanded_message_ = MakeString(std::runtime_error::what(), "\n\n==> Context: ", context);
0035   }
0036 
0037  private:
0038   std::string expanded_message_;
0039 };
0040 
0041 #define fail_convert(...) ONNX_THROW_EX(ConvertError(MakeString(__VA_ARGS__)));
0042 
0043 void ExportModelProto(ModelProto* p_m, const std::shared_ptr<Graph>& g);
0044 
0045 std::unique_ptr<Graph> ImportModelProto(const ModelProto& mp);
0046 
0047 ModelProto PrepareOutput(const ModelProto& mp_in);
0048 
0049 void assertNonNull(const std::shared_ptr<Graph>& g);
0050 } // namespace ONNX_NAMESPACE