From 82bc21e35e7aed6ee93d06381096f7e71c2a3786 Mon Sep 17 00:00:00 2001 From: gwang-msft <62914304+gwang-msft@users.noreply.github.com> Date: Fri, 21 Aug 2020 17:43:11 -0700 Subject: [PATCH] Namespace change on ort flatbuffers schema (#4886) * correct some errors in the flatbuffers schema, move flatbuffers submodule to cmake/external * update the ort flatbuffers schema to use less namespace * minor update Co-authored-by: gwang0000 <62914304+gwang0000@users.noreply.github.com> --- .gitmodules | 4 +- cgmanifests/submodules/cgmanifest.json | 20 ++++----- cmake/external/flatbuffers | 1 + flatbuffers | 1 - onnxruntime/core/flatbuffers/ort.fbs | 60 +++++++++++++------------- 5 files changed, 42 insertions(+), 44 deletions(-) create mode 160000 cmake/external/flatbuffers delete mode 160000 flatbuffers diff --git a/.gitmodules b/.gitmodules index de7959418f..d8d82bf3ce 100644 --- a/.gitmodules +++ b/.gitmodules @@ -62,6 +62,6 @@ [submodule "cmake/external/onnx-tensorrt"] path = cmake/external/onnx-tensorrt url = https://github.com/onnx/onnx-tensorrt.git -[submodule "flatbuffers"] - path = flatbuffers +[submodule "cmake/external/flatbuffers"] + path = cmake/external/flatbuffers url = https://github.com/google/flatbuffers.git diff --git a/cgmanifests/submodules/cgmanifest.json b/cgmanifests/submodules/cgmanifest.json index dc04424dfd..17bd294767 100644 --- a/cgmanifests/submodules/cgmanifest.json +++ b/cgmanifests/submodules/cgmanifest.json @@ -81,6 +81,16 @@ "comments": "git submodule at cmake/external/eigen" } }, + { + "component": { + "type": "git", + "git": { + "commitHash": "db2aa9b4eca0edc94aea9e2059c21ce8786fc762", + "repositoryUrl": "https://github.com/google/flatbuffers.git" + }, + "comments": "git submodule at cmake/external/flatbuffers" + } + }, { "component": { "type": "git", @@ -531,16 +541,6 @@ "comments": "git submodule at cmake/external/wil" } }, - { - "component": { - "type": "git", - "git": { - "commitHash": "f3003e08d02ca4810924a53ca463a8b3150926d8", - "repositoryUrl": "https://github.com/google/flatbuffers.git" - }, - "comments": "git submodule at flatbuffers" - } - }, { "component": { "type": "git", diff --git a/cmake/external/flatbuffers b/cmake/external/flatbuffers new file mode 160000 index 0000000000..db2aa9b4ec --- /dev/null +++ b/cmake/external/flatbuffers @@ -0,0 +1 @@ +Subproject commit db2aa9b4eca0edc94aea9e2059c21ce8786fc762 diff --git a/flatbuffers b/flatbuffers deleted file mode 160000 index f3003e08d0..0000000000 --- a/flatbuffers +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f3003e08d02ca4810924a53ca463a8b3150926d8 diff --git a/onnxruntime/core/flatbuffers/ort.fbs b/onnxruntime/core/flatbuffers/ort.fbs index c016ccfede..45d4463ec5 100644 --- a/onnxruntime/core/flatbuffers/ort.fbs +++ b/onnxruntime/core/flatbuffers/ort.fbs @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -namespace onnxruntime.experimental.fbs.Attribute; +namespace onnxruntime.experimental.fbs; -enum Type : int { +// Attribute +enum AttributeType : int { UNDEFINED = 0, FLOAT = 1, INT = 2, @@ -19,9 +20,8 @@ enum Type : int { SPARSE_TENSORS = 12, } -namespace onnxruntime.experimental.fbs.Tensor.Shape; - -table Info { +// Shape +table Shape { dim:[Dimension]; } @@ -35,9 +35,8 @@ table DimensionValue { dim_param:string; } -namespace onnxruntime.experimental.fbs.Tensor; - -enum DataType : int { +// Tensor +enum TensorDataType : int { UNDEFINED = 0, FLOAT = 1, UINT8 = 2, @@ -57,13 +56,12 @@ enum DataType : int { BFLOAT16 = 16, } -table TypeInfo{ - elem_type:DataType; - shape:Shape.Info; +table TensorTypeAndShape{ + elem_type:TensorDataType; + shape:Shape; } -namespace onnxruntime.experimental.fbs.Graph; - +// Node enum NodeType : int { Primitive = 0, Fused = 1, @@ -85,7 +83,7 @@ table Node { op_type:string; type:NodeType; execution_provider_type:string; - + inputs:[string]; outputs:[string]; attributes:[onnxruntime.experimental.fbs.Attribute]; @@ -94,13 +92,7 @@ table Node { implicit_inputs:[string]; } -namespace onnxruntime.experimental.fbs; - -table OperatorSetId { - domain:string; - version:long; -} - +// ValueInfo table ValueInfo { name:string; doc_string:string; @@ -109,7 +101,7 @@ table ValueInfo { // TODO add support of Sequence/Map/SparseTensor/Opaque union TypeInfoValue { - tensor_type:Tensor.TypeInfo, + tensor_type:TensorTypeAndShape, } table TypeInfo { @@ -117,15 +109,21 @@ table TypeInfo { value:TypeInfoValue; } +// OpSetId +table OperatorSetId { + domain:string; + version:long; +} + // For simplicity, we will have only two data fields // - string_data for string // - raw_data for all other types table Tensor { name:string; doc_string:string; - + dims:[long]; - data_type:Tensor.DataType; + data_type:TensorDataType; raw_data:[ubyte]; @@ -136,15 +134,15 @@ table Tensor { table Attribute{ name:string; doc_string:string; - - type:Attribute.Type; - + + type:AttributeType; + f:float; i:long; s:[ubyte]; t:Tensor; g:Graph; - + floats:[float]; ints:[long]; strings:[string]; @@ -156,11 +154,11 @@ table Graph{ initializers:[Tensor]; node_args:[ValueInfo]; - nodes:[Graph.Node]; + nodes:[Node]; max_node_index:uint; - input_edges:[Graph.EdgeEnd]; - output_edges:[Graph.EdgeEnd]; + input_edges:[EdgeEnd]; + output_edges:[EdgeEnd]; inputs:[string]; outputs:[string];