Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#include <unordered_map>
 
#include "core/common/flatbuffers.h"
 
#include "core/common/common.h"
#include "core/common/path_string.h"
#include "core/common/status.h"
 
namespace ONNX_NAMESPACE {
class ValueInfoProto;
}
 
namespace onnxruntime {
 
namespace fbs {
struct OperatorSetId;
struct ValueInfo;
 
namespace utils {
 
constexpr auto kInvalidOrtFormatModelMessage = "Invalid ORT format model.";
 
// Will only create string in flatbuffers when has_string is true
flatbuffers::Offset<flatbuffers::String> SaveStringToOrtFormat(flatbuffers::FlatBufferBuilder& builder,
                                                               bool has_string, const std::string& src);
 
onnxruntime::common::Status SaveValueInfoOrtFormat(
    flatbuffers::FlatBufferBuilder& builder, const ONNX_NAMESPACE::ValueInfoProto& value_info_proto,
    flatbuffers::Offset<fbs::ValueInfo>& fbs_value_info);
 
void LoadStringFromOrtFormat(std::string& dst, const flatbuffers::String* fbs_string);
 
// This macro is to be used on a protobuf message (protobuf_msg), which will not create an empty string field (str_field)
// if fbs_string is null
#define LOAD_STR_FROM_ORT_FORMAT(protobuf_msg, str_field, fbs_string) \
  {                                                                   \
    if (fbs_string)                                                   \
      protobuf_msg.set_##str_field(fbs_string->str());                \
  }
 
onnxruntime::common::Status LoadValueInfoOrtFormat(
    const fbs::ValueInfo& fbs_value_info, ONNX_NAMESPACE::ValueInfoProto& value_info_proto);
 
onnxruntime::common::Status LoadOpsetImportOrtFormat(
    const flatbuffers::Vector<flatbuffers::Offset<fbs::OperatorSetId>>* fbs_op_set_ids,
    std::unordered_map<std::string, int>& domain_to_version);
 
// check if filename ends in .ort
bool IsOrtFormatModel(const PathString& filename);
 
// check if bytes has the flatbuffer ORT identifier
bool IsOrtFormatModelBytes(const void* bytes, int num_bytes);
 
}  // namespace utils
}  // namespace fbs
}  // namespace onnxruntime
 
#define ORT_FORMAT_RETURN_IF_NULL(expr, expr_description)            \
  ORT_RETURN_IF((expr) == nullptr, (expr_description), " is null. ", \
                onnxruntime::fbs::utils::kInvalidOrtFormatModelMessage)