Исходный код СУБД 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#pragma once
 
#if !defined(ORT_MINIMAL_BUILD)
 
#include <string>
#include <string_view>
#include <unordered_map>
 
#include "core/common/common.h"
#include "core/common/inlined_containers.h"
 
namespace ONNX_NAMESPACE {
class FunctionProto;
class ModelProto;
}  // namespace ONNX_NAMESPACE
 
namespace onnxruntime {
 
/// Adjacency list representation of a local function call graph.
/// Keys and values are string_views into stable storage (e.g. map keys that outlive this structure).
using LocalFunctionCallGraph = InlinedHashMap<std::string_view, InlinedVector<std::string_view>>;
 
constexpr size_t kMaxModelSubgraphDepth = 32;
 
Status ValidateModelSubgraphDepth(const ONNX_NAMESPACE::ModelProto& model_proto);
Status ValidateFunctionSubgraphDepth(const ONNX_NAMESPACE::FunctionProto& function_proto);
 
/// Build a call graph adjacency list from model local functions.
/// String views in the returned graph point into the keys of @p model_local_functions.
Status BuildLocalFunctionCallGraph(
    const std::unordered_map<std::string, const ONNX_NAMESPACE::FunctionProto*>& model_local_functions,
    LocalFunctionCallGraph& call_graph);
 
/// Validate that a call graph contains no cycles.
/// Returns an error with the cycle path if a cycle is detected.
Status ValidateCallGraphAcyclic(const LocalFunctionCallGraph& call_graph);
 
/// Convenience: build the call graph from model local functions and validate acyclicity.
Status ValidateModelLocalFunctionAcyclic(
    const std::unordered_map<std::string, const ONNX_NAMESPACE::FunctionProto*>& model_local_functions);
 
}  // namespace onnxruntime
 
#endif  // !defined(ORT_MINIMAL_BUILD)