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

Function Execute_MatMul_XLA_CPU

tensorflow/c/eager/c_api_test.cc:1171–1209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1169
1170#ifdef TENSORFLOW_EAGER_USE_XLA
1171void Execute_MatMul_XLA_CPU(bool async) {
1172 TF_Status* status = TF_NewStatus();
1173 TFE_ContextOptions* opts = TFE_NewContextOptions();
1174 TFE_ContextOptionsSetAsync(opts, static_cast<unsigned char>(async));
1175 TFE_Context* ctx = TFE_NewContext(opts, status);
1176 CHECK_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
1177 TFE_DeleteContextOptions(opts);
1178
1179 TFE_TensorHandle* m = TestMatrixTensorHandle();
1180 TFE_Op* matmul = MatMulOp(ctx, m, m);
1181
1182 TFE_OpSetXLACompilation(matmul, true);
1183
1184 TFE_TensorHandle* retvals[1] = {nullptr};
1185 int num_retvals = 1;
1186 TFE_Execute(matmul, &retvals[0], &num_retvals, status);
1187 // Running a primitive TF operator via XLA is not yet supported.
1188 ASSERT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
1189
1190 TFE_DeleteOp(matmul);
1191 TFE_DeleteTensorHandle(m);
1192 ASSERT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
1193
1194 EXPECT_EQ(1, num_retvals);
1195
1196 TF_Tensor* t = TFE_TensorHandleResolve(retvals[0], status);
1197 TFE_DeleteTensorHandle(retvals[0]);
1198 ASSERT_EQ(TF_OK, TF_GetCode(status)) << TF_Message(status);
1199 float product[4] = {0};
1200 EXPECT_EQ(sizeof(product), TF_TensorByteSize(t));
1201 memcpy(&product[0], TF_TensorData(t), TF_TensorByteSize(t));
1202 TF_DeleteTensor(t);
1203 EXPECT_EQ(7, product[0]);
1204 EXPECT_EQ(10, product[1]);
1205 EXPECT_EQ(15, product[2]);
1206 EXPECT_EQ(22, product[3]);
1207 TFE_DeleteContext(ctx);
1208 TF_DeleteStatus(status);
1209}
1210TEST(CAPI, Execute_MatMul_XLA_CPU) { Execute_MatMul_XLA_CPU(false); }
1211TEST(CAPI, Execute_MatMul_XLA_CPUAsync) { Execute_MatMul_XLA_CPU(true); }
1212

Callers 1

TESTFunction · 0.85

Calls 15

TF_NewStatusFunction · 0.85
TFE_NewContextOptionsFunction · 0.85
TFE_NewContextFunction · 0.85
TF_GetCodeFunction · 0.85
TF_MessageFunction · 0.85
TFE_DeleteContextOptionsFunction · 0.85
TestMatrixTensorHandleFunction · 0.85
TFE_OpSetXLACompilationFunction · 0.85
TFE_ExecuteFunction · 0.85
TFE_DeleteOpFunction · 0.85
TFE_DeleteTensorHandleFunction · 0.85

Tested by

no test coverage detected