junxnone / tio

Log
Other
10 stars 5 forks source link

ONNX - Optimizer #740

Open junxnone opened 4 years ago

junxnone commented 4 years ago

Reference

Brief

optimize(model, passes=None, fixed_point=False)

Available optimization passes

Name Description

eliminate_deadend eliminate_identity eliminate_nop_dropout eliminate_nop_monotone_argmax eliminate_nop_pad eliminate_nop_transpose eliminate_unused_initializer extract_constant_to_initializer fuse_add_bias_into_conv fuse_bn_into_conv fuse_consecutive_concats fuse_consecutive_log_softmax fuse_consecutive_reduce_unsqueeze fuse_consecutive_squeezes fuse_consecutive_transposes fuse_matmul_add_bias_into_gemm fuse_pad_into_conv fuse_transpose_into_gemm lift_lexical_references nop split_init split_predict

Examples

optimize_onnx.ipynb

passes = ['fuse_consecutive_transposes'] optimized_model = optimizer.optimize(original_model, passes)

-  优化之前

graph two-transposes ( %X[FLOAT, 2x3x4] ) { %Y = Transposeperm = [1, 0, 2] %Z = Transposeperm = [1, 0, 2] return %Z }

- 优化之后 - 优化 `fuse_consecutive_transposes`

graph two-transposes ( %X[FLOAT, 2x3x4] ) { %Z = Transposeperm = [0, 1, 2] return %Z }



## Implementing Optimization Passes
junxnone commented 4 years ago

734