Spaces:
Sleeping
Sleeping
File size: 1,356 Bytes
dc2106c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
// Copyright (c) ONNX Project Contributors
/*
* SPDX-License-Identifier: Apache-2.0
*/
// ATTENTION: The code in this file is highly EXPERIMENTAL.
// Adventurous users should note that the APIs will probably change.
#pragma once
#include <memory>
#include <string>
#include "onnx/common/common.h"
#include "onnx/common/ir.h"
#include "onnx/onnx_pb.h"
namespace ONNX_NAMESPACE {
class ConvertError final : public std::runtime_error {
public:
using std::runtime_error::runtime_error;
explicit ConvertError(const std::string& message) : std::runtime_error(message) {}
const char* what() const noexcept override {
if (!expanded_message_.empty()) {
return expanded_message_.c_str();
}
return std::runtime_error::what();
}
void AppendContext(const std::string& context) {
expanded_message_ = MakeString(std::runtime_error::what(), "\n\n==> Context: ", context);
}
private:
std::string expanded_message_;
};
#define fail_convert(...) ONNX_THROW_EX(ConvertError(MakeString(__VA_ARGS__)));
void ExportModelProto(ModelProto* p_m, const std::shared_ptr<Graph>& g);
std::unique_ptr<Graph> ImportModelProto(const ModelProto& mp);
ModelProto PrepareOutput(const ModelProto& mp_in);
void assertNonNull(const std::shared_ptr<Graph>& g);
} // namespace ONNX_NAMESPACE
|