MatMulGrad helper function used to compute two MatMul operations based on input matrix transposition combinations.
| 1061 | // MatMulGrad helper function used to compute two MatMul operations |
| 1062 | // based on input matrix transposition combinations. |
| 1063 | Status MatMulGradHelper(const Scope& scope, const bool is_batch, |
| 1064 | const Output& x0, const bool adj_x0, const Output& x1, |
| 1065 | const bool adj_x1, const Output& y0, const bool adj_y0, |
| 1066 | const Output& y1, const bool adj_y1, |
| 1067 | std::vector<Output>* grad_outputs) { |
| 1068 | if (is_batch == false) { |
| 1069 | auto dx = |
| 1070 | MatMul(scope, x0, x1, MatMul::TransposeA(adj_x0).TransposeB(adj_x1)); |
| 1071 | grad_outputs->push_back(dx); |
| 1072 | auto dy = |
| 1073 | MatMul(scope, y0, y1, MatMul::TransposeA(adj_y0).TransposeB(adj_y1)); |
| 1074 | grad_outputs->push_back(dy); |
| 1075 | } else { |
| 1076 | auto dx = |
| 1077 | BatchMatMul(scope, x0, x1, BatchMatMul::AdjX(adj_x0).AdjY(adj_x1)); |
| 1078 | grad_outputs->push_back(dx); |
| 1079 | auto dy = |
| 1080 | BatchMatMul(scope, y0, y1, BatchMatMul::AdjX(adj_y0).AdjY(adj_y1)); |
| 1081 | grad_outputs->push_back(dy); |
| 1082 | } |
| 1083 | return scope.status(); |
| 1084 | } |
| 1085 | |
| 1086 | // MatMulGrad common used to read and check node attr state, and determine |
| 1087 | // proper MatMul products for gradients based on input matrix transposition |
no test coverage detected