MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / MatMulGradHelper

Function MatMulGradHelper

tensorflow/cc/gradients/math_grad.cc:1063–1084  ·  view source on GitHub ↗

MatMulGrad helper function used to compute two MatMul operations based on input matrix transposition combinations.

Source from the content-addressed store, hash-verified

1061// MatMulGrad helper function used to compute two MatMul operations
1062// based on input matrix transposition combinations.
1063Status 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

Callers 1

MatMulGradCommonFunction · 0.70

Calls 4

BatchMatMulFunction · 0.85
MatMulFunction · 0.50
push_backMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected