forked from mindspore-Ecosystem/mindspore
154 lines
2.6 KiB
Plaintext
154 lines
2.6 KiB
Plaintext
/**
|
|
* Copyright 2019 Huawei Technologies Co., Ltd
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
include "op.fbs";
|
|
|
|
namespace mindspore.predict;
|
|
|
|
enum DataType : int {
|
|
DT_FLOAT = 0,
|
|
DT_FLOAT16 = 1,
|
|
DT_INT8 = 2,
|
|
DT_INT32 = 3,
|
|
DT_UINT8 = 4,
|
|
DT_UINT32 = 8,
|
|
DT_UNDEFINED = 16
|
|
}
|
|
|
|
enum Format : int {
|
|
NCHW = 0,
|
|
NHWC,
|
|
NC4HW4 = 100,
|
|
NUM_OF_FORMAT
|
|
}
|
|
|
|
enum MSConst: int {
|
|
WEIGHT_REFCOUNT = 999
|
|
}
|
|
|
|
table QuantizationDef {
|
|
// Quantized value q, corresponding float value r:
|
|
// r = scale * (q - zero_point), where scale = (rmax - rmin) / (qmax - qmin)
|
|
min: [float];
|
|
max: [float];
|
|
scale: [float];
|
|
zero_point: [long];
|
|
|
|
// Tensor shape of the specifies dimension.
|
|
dimension: int;
|
|
}
|
|
|
|
table TensorDef {
|
|
// data type
|
|
dataType: DataType;
|
|
// shape
|
|
dims: [int];
|
|
format: Format;
|
|
refCount: int;
|
|
offset: int;
|
|
data: [ubyte];
|
|
quantization: QuantizationDef;
|
|
}
|
|
|
|
union OpT {
|
|
Concat,
|
|
SoftMax,
|
|
Activation,
|
|
Conv2D,
|
|
FusedBatchNorm,
|
|
CaffeBatchNorm,
|
|
Squeeze,
|
|
BiasAdd,
|
|
Pooling,
|
|
DepthwiseConv2D,
|
|
DeDepthwiseConv2D,
|
|
Resize,
|
|
DetectionPostProcess,
|
|
FullConnection,
|
|
Mean,
|
|
DeConv2D,
|
|
Scale,
|
|
Reshape,
|
|
Eltwise,
|
|
NetOutput,
|
|
Add,
|
|
MatMul,
|
|
StridedSlice,
|
|
Power,
|
|
Slice,
|
|
Stack,
|
|
Mul,
|
|
Pad,
|
|
Maximum,
|
|
CaffePReLU,
|
|
ArgMax,
|
|
Exp,
|
|
CaffeCrop,
|
|
Range,
|
|
ExpandDims,
|
|
Tile,
|
|
Cast
|
|
// Split
|
|
}
|
|
|
|
enum QuantType: int {
|
|
QUANT_NONE,
|
|
QUANT_INT8
|
|
}
|
|
|
|
table OpDef {
|
|
name: string;
|
|
attr: OpT;
|
|
inputIndex: [uint];
|
|
outputIndex: [uint];
|
|
isLastConv: bool;
|
|
quantType: QuantType = QUANT_NONE;
|
|
}
|
|
|
|
|
|
enum FmkType: int {
|
|
TF,
|
|
CAFFE
|
|
}
|
|
|
|
table NodeDef {
|
|
fmkType: FmkType;
|
|
opDef: OpDef;
|
|
}
|
|
|
|
|
|
table SubGraphDef {
|
|
name: string;
|
|
inputIndex: [uint];
|
|
outputIndex: [uint];
|
|
mempoolSize: uint;
|
|
nodes: [NodeDef];
|
|
allTensors: [TensorDef]; // weight + input + output
|
|
}
|
|
|
|
table MempoolCfg {
|
|
size: uint;
|
|
shiftFactor: uint;
|
|
}
|
|
|
|
table GraphDef {
|
|
name: string;
|
|
mempoolCfg: MempoolCfg;
|
|
subgraphs: [SubGraphDef];
|
|
}
|
|
|
|
root_type GraphDef;
|