| 249 | } |
| 250 | |
| 251 | Tensor MatMulCommon(const string& opname, const string& attr_adj_x, |
| 252 | const string& attr_adj_y, const Tensor& x, bool ax, |
| 253 | const Tensor& y, bool ay) { |
| 254 | auto T = x.dtype(); |
| 255 | auto gdef = test::function::GDef( |
| 256 | { |
| 257 | f::NDef("x", "Placeholder", {}, {{"dtype", T}}), |
| 258 | f::NDef("y", "Placeholder", {}, {{"dtype", T}}), |
| 259 | f::NDef("z", opname, {"x", "y"}, |
| 260 | {{"T", T}, {attr_adj_x, ax}, {attr_adj_y, ay}}), |
| 261 | }, |
| 262 | {}); |
| 263 | auto sess = NewSession(); |
| 264 | TF_CHECK_OK(sess->Create(gdef)); |
| 265 | std::vector<Tensor> outputs; |
| 266 | TF_CHECK_OK(sess->Run({{"x:0", x}, {"y:0", y}}, {"z:0"}, {}, &outputs)); |
| 267 | CHECK_EQ(outputs.size(), 1); |
| 268 | TF_CHECK_OK(sess->Close()); |
| 269 | return outputs[0]; |
| 270 | } |
| 271 | |
| 272 | Tensor MatMul(const Tensor& x, bool ax, const Tensor& y, bool ay) { |
| 273 | return MatMulCommon("MatMul", "transpose_a", "transpose_b", x, ax, y, ay); |