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

Method TestMatMulGrad

tensorflow/cc/gradients/math_grad_test.cc:584–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

582
583 template <typename T>
584 void TestMatMulGrad(const bool is_batch, const bool t_x, const bool t_y) {
585 TF_ASSERT_OK(root_.status());
586 // Generate random (but compatible) shapes for matrix multiplication.
587 std::vector<TensorShape> shapes;
588 RandMatMulShapes(is_batch, t_x, t_y, &shapes);
589 TensorShape x_shape = shapes[0];
590 TensorShape y_shape = shapes[1];
591 TensorShape z_shape = shapes[2];
592 auto x =
593 Placeholder(root_, DataTypeToEnum<T>::v(), Placeholder::Shape(x_shape));
594 auto y =
595 Placeholder(root_, DataTypeToEnum<T>::v(), Placeholder::Shape(y_shape));
596 Output z;
597 if (is_batch) {
598 z = BatchMatMul(root_, x, y, BatchMatMul::AdjX(t_x).AdjY(t_y));
599 } else {
600 z = MatMul(root_, x, y, MatMul::TransposeA(t_x).TransposeB(t_y));
601 }
602
603 float max_error;
604 TF_ASSERT_OK((ComputeGradientError<T, T, float>(
605 root_, {x, y}, {x_shape, y_shape}, {z}, {z_shape}, &max_error)));
606 EXPECT_LT(max_error, 1e-3);
607 }
608
609 void RandMatMulShapes(const bool is_batch, const bool tx, const bool ty,
610 std::vector<TensorShape>* shapes) {

Callers

nothing calls this directly

Calls 5

BatchMatMulFunction · 0.85
PlaceholderFunction · 0.50
ShapeClass · 0.50
MatMulFunction · 0.50
statusMethod · 0.45

Tested by

no test coverage detected