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

Function MatMulGradCommon

tensorflow/core/ops/math_grad.cc:849–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

847}
848
849Status MatMulGradCommon(const string& opname, const string& attr_adj_x,
850 const string& attr_adj_y, const AttrSlice& attrs,
851 FunctionDef* g, bool enable_broadcasting) {
852 DataType T;
853 TF_RETURN_IF_ERROR(GetNodeAttr(attrs, "T", &T));
854 if (T == DT_COMPLEX64 || T == DT_COMPLEX128) {
855 return errors::Unimplemented(
856 "MatMul gradient for complex is not supported yet.");
857 }
858 bool ta;
859 bool tb;
860 TF_RETURN_IF_ERROR(GetNodeAttr(attrs, attr_adj_x, &ta));
861 TF_RETURN_IF_ERROR(GetNodeAttr(attrs, attr_adj_y, &tb));
862 if (!ta && !tb) {
863 return MatMulGradHelper(g, opname, attr_adj_x, attr_adj_y, "dz", false, "y",
864 true, "x", true, "dz", false, enable_broadcasting);
865 }
866 if (!ta && tb) {
867 return MatMulGradHelper(g, opname, attr_adj_x, attr_adj_y, "dz", false, "y",
868 false, "dz", true, "x", false, enable_broadcasting);
869 }
870 if (ta && !tb) {
871 return MatMulGradHelper(g, opname, attr_adj_x, attr_adj_y, "y", false, "dz",
872 true, "x", false, "dz", false, enable_broadcasting);
873 }
874 CHECK(ta && tb);
875 return MatMulGradHelper(g, opname, attr_adj_x, attr_adj_y, "y", true, "dz",
876 true, "dz", true, "x", true, enable_broadcasting);
877}
878
879Status MatMulGrad(const AttrSlice& attrs, FunctionDef* g) {
880 return MatMulGradCommon("MatMul", "transpose_a", "transpose_b", attrs, g,

Callers 6

MatMulGradMethod · 0.70
BatchMatMulGradMethod · 0.70
BatchMatMulV2GradMethod · 0.70
MatMulGradFunction · 0.70
BatchMatMulGradFunction · 0.70
BatchMatMulV2GradFunction · 0.70

Calls 3

UnimplementedFunction · 0.85
MatMulGradHelperFunction · 0.70
GetNodeAttrFunction · 0.50

Tested by 3

MatMulGradMethod · 0.56
BatchMatMulGradMethod · 0.56
BatchMatMulV2GradMethod · 0.56