Skip to content

Latest commit

History

History
16 lines (14 loc) 路 3.01 KB

matmul.md

File metadata and controls

16 lines (14 loc) 路 3.01 KB
WebNN matmul a b output
NNAPI ANEURALNETWORKS_FULLY_CONNECTED if N > 3, reshape (ANEURALNETWORKS_RESHAPE) to 3-D tensor. if N == 3, slice (ANEURALNETWORKS_RESHAPE) to 2-D tensors along axis 0. Use inputs[0] of ANEURALNETWORKS_FULLY_CONNECTED if N > 3, reshape (ANEURALNETWORKS_RESHAPE) to 3-D tensor. if N == 3, slice (ANEURALNETWORKS_RESHAPE) to 2-D tensors along left axis. Transpose the tensor (ANEURALNETWORKS_TRANSPOSE). Use inputs[1] of ANEURALNETWORKS_FULLY_CONNECTED As ANEURALNETWORKS_FULLY_CONNECTED output is 2-D, need to reshape (ANEURALNETWORKS_RESHAPE) to 3-D tensors, concat (ANEURALNETWORKS_CONCATENATION) along axis 9 and reshape (ANEURALNETWORKS_RESHAPE) to N-D.
DirectML DML_GEMM_OPERATOR_DESC when: DML_GEMM_OPERATOR_DESC::Alpha == 1.0, DML_GEMM_OPERATOR_DESC::Beta == 0, DML_GEMM_OPERATOR_DESC::TransA == DML_MATRIX_TRANSFORM_NONE, DML_GEMM_OPERATOR_DESC::TransB == DML_MATRIX_TRANSFORM_NONE, DML_GEMM_OPERATOR_DESC::CTensor == null ATensor of DML_GEMM_OPERATOR_DESC BTensor of DML_GEMM_OPERATOR_DESC OutputTensor of DML_GEMM_OPERATOR_DESC
MPS MPSNDArrayMatrixMultiplication or MPSMatrixMultiplication or MPSCNNFullyConnected?
BNNS BNNSFilterCreateFullyConnectedLayer or vDSP_mmul?
DNNL matmul f N > 3, reorder to 3-D tensor. Use DNNL_ARG_SRC of matmul primitive. If N > 3, reorder to 3-D tensor. Use DNNL_ARG_WEIGHTS of matmul primitive. Use DNNL_ARG_DST of matmul primitive. If N > 3, need to reorder to N-D.
ONNX MatMul A B Y

References:

Opens:

  • NNAPI: for N-D output when N >2, is it correct to map TF-Lite Pack op to NNAPI ANEURALNETWORKS_RESHAPE and ANEURALNETWORKS_CONCATENATION ops?
  • MPS: which is the right op to map?
  • BNNS: which is the right op to map?