Open junxnone opened 4 years ago
optimize(model, passes=None, fixed_point=False)
passes
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
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
Reference
Brief
passes
Available optimization passes
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 }
graph two-transposes ( %X[FLOAT, 2x3x4] ) { %Z = Transposeperm = [0, 1, 2] return %Z }