add ppyolov3 convert (#298)

pull/301/head
郑启航 2021-07-26 00:25:43 +08:00 committed by GitHub
parent 38ea39f893
commit a3ffe8349e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 184 additions and 135 deletions

View File

@ -1,14 +1,16 @@
## Supported Caffe ops
## 支持的 Caffe 算子
| Operator | Is Supported |
|-------|------------------ |
| Concat |✅|
| Convolution |✅|
| Eltwise |✅|
| Permute |✅|
| ReLU |✅|
| Reshape |✅|
| Slice |✅|
| Softmax |✅|
| Split |✅|
| Input | ✅ |
| Concat | ✅ |
| Convolution | ✅ |
| Eltwise | ✅ |
| Permute | ✅ |
| Relu | ✅ |
| Reshape | ✅ |
| Slice | ✅ |
| Softmax | ✅ |
| Split | ✅ |

View File

@ -1,41 +1,63 @@
## Supported ONNX ops
## 支持的 ONNX 算子
| Operator | Is Supported |
|-------|------------------ |
| Abs |✅|
| Add |✅|
| AveragePool |✅|
| Ceil |✅|
| Concat |✅|
| Constant |✅|
| Conv |✅|
| ConvTranspose |✅|
| Cos |✅|
| Div |✅|
| Exp |✅|
| Floor |✅|
| LpNormalization |✅|
| LeakyRelu |✅|
| Log |✅|
| MatMul |✅|
| MaxPool |✅|
| Max |✅|
| Min |✅|
| Mul |✅|
| Neg |✅|
| Pad |✅|
| ReduceMax |✅|
| ReduceMean |✅|
| ReduceMin |✅|
| ReduceSum |✅|
| Relu |✅|
| Reshape |✅|
| Resize |✅|
| Sin |✅|
| Slice |✅|
| Softmax |✅|
| Sqrt |✅|
| Squeeze |✅|
| Sub |✅|
| Transpose |✅|
| Abs | ✅ |
| Add | ✅ |
| Averagepool | ✅ |
| Batchnormalization | ✅ |
| Ceil | ✅ |
| Clip | ✅ |
| Concat | ✅ |
| Constant | ✅ |
| Conv | ✅ |
| Convtranspose | ✅ |
| Cos | ✅ |
| Div | ✅ |
| Dropout | ✅ |
| Exp | ✅ |
| Flatten | ✅ |
| Floor | ✅ |
| Gather | ✅ |
| Gathernd | ✅ |
| Gemm | ✅ |
| Globalaveragepool | ✅ |
| Globalmaxpool | ✅ |
| Identity | ✅ |
| Instancenormalization | ✅ |
| Lpnormalization | ✅ |
| Leakyrelu | ✅ |
| Log | ✅ |
| Lrn | ✅ |
| Matmul | ✅ |
| Maxpool | ✅ |
| Max | ✅ |
| Min | ✅ |
| Mul | ✅ |
| Neg | ✅ |
| Onehot | ✅ |
| Pad | ✅ |
| Pow | ✅ |
| Prelu | ✅ |
| Reducemax | ✅ |
| Reducemean | ✅ |
| Reducemin | ✅ |
| Reducesum | ✅ |
| Relu | ✅ |
| Reshape | ✅ |
| Resize | ✅ |
| Round | ✅ |
| Sin | ✅ |
| Sigmoid | ✅ |
| Slice | ✅ |
| Softmax | ✅ |
| Spacetodepth | ✅ |
| Sqrt | ✅ |
| Squeeze | ✅ |
| Sub | ✅ |
| Sum | ✅ |
| Transpose | ✅ |
| Upsample | ✅ |
| Unsqueeze | ✅ |

8
docs/paddle_ops.md Normal file
View File

@ -0,0 +1,8 @@
## Supported PaddlePaddle ops
## 支持的 PaddlePaddle 算子
| Operator | Is Supported |
|-------|------------------ |
| Feed | ✅ |
| Conv2d | ✅ |

View File

@ -1,93 +1,68 @@
## Supported TensorFlow Lite ops
## 支持的 TensorFlow Lite 算子
| Operator | Is Supported |
|-------|------------------ |
| Add |✅|
| ArgMax |❌|
| ArgMin |❌|
| AveragePool2D |✅|
| BatchToSpaceND |❌|
| Cast |❌|
| Concatenation |✅|
| Conv2D |✅|
| DepthwiseConv2D |✅|
| Div |✅|
| Equal |❌|
| Exp |✅|
| ExpandDims |❌|
| Floor |✅|
| FullyConnected |✅|
| Gather |❌|
| Greater |❌|
| GreaterEqual |❌|
| MaxPool2D |✅|
| Mean |✅|
| Mul |✅|
| L2Normalization |✅|
| L2Pool2D |❌|
| LeakyRelu |✅|
| LessEqual |❌|
| Log |✅|
| Logistic |✅|
| LogSoftmax |❌|
| Maximum |✅|
| Minimum |✅|
| Neg |✅|
| NotEqual |❌|
| Pack |❌|
| Pad |✅|
| Pow |❌|
| PRelu |❌|
| ReduceMax |✅|
| ReduceProd |❌|
| Relu |✅|
| Relu6 |✅|
| Reshape |✅|
| ResizeBilinear |✅|
| Rsqrt |✅|
| Select |❌|
| Shape |❌|
| Sin |✅|
| Slice |✅|
| Softmax |✅|
| SpaceToDepth |❌|
| SpaceToBatchND |❌|
| SparseToDense |❌|
| Split |❌|
| Sqrt |✅|
| Square |✅|
| Squeeze |❌|
| StridedSlice |✅|
| Sub |✅|
| Sum |✅|
| Tile |❌|
| TopK |❌|
| Transpose |✅|
| TransposeConv |✅|
| LogicalOr |❌|
| OneHot |❌|
| LogicalAnd |❌|
| LogicalNot |❌|
| UnPack |❌|
| ReduceMin |✅|
| FloorDiv |❌|
| ReduceAny |❌|
| ZerosLike |❌|
| Fill |❌|
| FloorMod |❌|
| Range |❌|
| ResizeNearesetNeighbor |✅|
| MirrorPad |❌|
| Abs |✅|
| SplitV |❌|
| Unique |❌|
| Ceil |✅|
| Reverse |❌|
| AddN |❌|
| GatherND |❌|
| Cos |✅|
| Where |❌|
| Rank |❌|
| Elu |❌|
| ReverseSequence |❌|
| Abs | ✅ |
| Add | ✅ |
| Average_pool_2d | ✅ |
| Cast | ✅ |
| Ceil | ✅ |
| Concatenation | ✅ |
| Conv_2d | ✅ |
| Cos | ✅ |
| Depthwise_conv_2d | ✅ |
| Div | ✅ |
| Exp | ✅ |
| Floor | ✅ |
| Floor_div | ✅ |
| Floor_mod | ✅ |
| Fully_connected | ✅ |
| L2_normalization | ✅ |
| Leaky_relu | ✅ |
| Log | ✅ |
| Logistic | ✅ |
| Max_pool_2d | ✅ |
| Maximum | ✅ |
| Mean | ✅ |
| Minimum | ✅ |
| Mul | ✅ |
| Neg | ✅ |
| Pad | ✅ |
| Padv2 | ✅ |
| Mirror_pad | ✅ |
| Pack | ✅ |
| Pow | ✅ |
| Reduce_max | ✅ |
| Reduce_min | ✅ |
| Relu | ✅ |
| Relu6 | ✅ |
| Reshape | ✅ |
| Resize_bilinear | ✅ |
| Resize_nearest_neighbor | ✅ |
| Round | ✅ |
| Rsqrt | ✅ |
| Shape | ✅ |
| Sin | ✅ |
| Slice | ✅ |
| Softmax | ✅ |
| Space_to_batch_nd | ✅ |
| Squeeze | ✅ |
| Batch_to_space_nd | ✅ |
| Strided_slice | ✅ |
| Sqrt | ✅ |
| Square | ✅ |
| Sub | ✅ |
| Sum | ✅ |
| Tanh | ✅ |
| Transpose | ✅ |
| Transpose_conv | ✅ |
| Quantize | ✅ |
| Fake_quant | ✅ |
| Dequantize | ✅ |
| Gather | ✅ |
| Gather_nd | ✅ |
| One_hot | ✅ |
| Squared_difference | ✅ |
| Log_softmax | ✅ |

View File

@ -625,7 +625,8 @@ template <>
float onnx_importer::to<float>(const onnx::TensorProto &tensor)
{
// assert(tensor.data_type() == tensor_type<float>);
assert(tensor.float_data_size() > 0);
if (!(tensor.float_data_size() > 0))
throw std::invalid_argument("the value has not found");
return tensor.float_data()[0];
}

View File

@ -33,6 +33,7 @@ DEFINE_OPCODE(Mul)
DEFINE_OPCODE(Neg)
DEFINE_OPCODE(OneHot)
DEFINE_OPCODE(Pad)
DEFINE_OPCODE(Pow)
DEFINE_OPCODE(PRelu)
DEFINE_OPCODE(ReduceMax)
DEFINE_OPCODE(ReduceMean)

View File

@ -53,6 +53,11 @@ void onnx_importer::convert_op_Max(const onnx::NodeProto &node)
convert_binary(node, binary_max);
}
void onnx_importer::convert_op_Pow(const onnx::NodeProto &node)
{
convert_binary(node, binary_pow);
}
void onnx_importer::convert_binary(const onnx::NodeProto &node, const binary_op_t binary_op)
{
assert(node.input().size() == 2);

View File

@ -121,7 +121,14 @@ void onnx_importer::convert_op_Pad(const NodeProto &node)
{
if (constant_initializer)
{
constant = to<float>(constant_initializer.value());
if (constant_initializer.value().float_data_size() == 0)
{
constant = 0.f;
}
else
{
constant = to<float>(constant_initializer.value());
}
}
else
{

View File

@ -0,0 +1,28 @@
import re
def get_file_header(name: str):
return f"""## Supported {name} ops
## 支持的 {name} 算子
| Operator | Is Supported |
|-------|------------------ |
"""
if __name__ == "__main__":
pattern = re.compile("\(([^)]*)\)")
for name, alias in (
('TensorFlow Lite', 'tflite'),
('Caffe', 'caffe'),
('ONNX', 'onnx'),
('PaddlePaddle', 'paddle'),
):
txt = get_file_header(name)
with open(f'src/importer/{alias}/opcode.def', 'r') as f:
opcodes = f.read()
for case in pattern.findall(opcodes):
txt += f'| {case.capitalize()} | ✅ |\n'
with open(f'docs/{alias}_ops.md', 'w') as f:
f.write(txt)