BatchMatMulReduceMeanFusionPass

Description

Adds the pad operator node to the constant input of the batchmatmul/batchmatmulv2/matmul/matmulv2/reducemean operator node to improve computing performance.

Before: After:

Restrictions

  • The input1 of the batchmatmul/batchmatmulv2/matmul/matmulv2 node must be a const node.
  • In the output matrix (m,n) or (b,m,n) of the batchmatmul/batchmatmulv2/matmul/matmulv2 node, the m dimension must be 16-pixel aligned, and the n dimension cannot be 16-pixel aligned.
  • The ReduceMean node must have the axes attribute, and the reduce operation of this node cannot be performed on the last axis.
  • The const input shape of the add operator must be 1-dimensional and consistent with the n-dimensional output of Matmul.