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

Function TensorHandleCopyBetweenDevicesError

tensorflow/c/eager/c_api_test.cc:655–685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

653}
654
655void TensorHandleCopyBetweenDevicesError(bool async) {
656 std::unique_ptr<TF_Status, decltype(&TF_DeleteStatus)> status(
657 TF_NewStatus(), TF_DeleteStatus);
658 TFE_ContextOptions* opts = TFE_NewContextOptions();
659 TFE_ContextOptionsSetAsync(opts, static_cast<unsigned char>(async));
660 TFE_Context* ctx = TFE_NewContext(opts, status.get());
661 TFE_DeleteContextOptions(opts);
662 ASSERT_EQ(TF_OK, TF_GetCode(status.get())) << TF_Message(status.get());
663 TFE_TensorHandle* hcpu = TestMatrixTensorHandle();
664 const char* kErrorDevice = "NoSuchDevice:0";
665 TFE_TensorHandle* hdevice =
666 TFE_TensorHandleCopyToDevice(hcpu, ctx, kErrorDevice, status.get());
667 EXPECT_NE(TF_OK, TF_GetCode(status.get()));
668 const char* msg = "NoSuchDevice:0 unknown device";
669 EXPECT_TRUE(strstr(TF_Message(status.get()), msg) != nullptr)
670 << TF_Message(status.get());
671 TF_SetStatus(status.get(), TF_OK, "");
672 const char* kCPUDevice = "CPU:0";
673 TFE_TensorHandle* hcopy =
674 TFE_TensorHandleCopyToDevice(hcpu, ctx, kCPUDevice, status.get());
675 EXPECT_EQ(TF_OK, TF_GetCode(status.get())) << TF_Message(status.get());
676
677 TFE_Executor* executor = TFE_ContextGetExecutorForThread(ctx);
678 TFE_ExecutorWaitForAllPendingNodes(executor, status.get());
679 EXPECT_EQ(TF_OK, TF_GetCode(status.get())) << TF_Message(status.get());
680 TFE_DeleteExecutor(executor);
681 TFE_DeleteTensorHandle(hcopy);
682 TFE_DeleteTensorHandle(hcpu);
683 if (hdevice != nullptr) TFE_DeleteTensorHandle(hdevice);
684 TFE_DeleteContext(ctx);
685}
686
687TEST(CAPI, TensorHandleCopyBetweenDevicesError) {
688 TensorHandleCopyBetweenDevicesError(false);

Callers 1

TESTFunction · 0.85

Calls 15

TF_NewStatusFunction · 0.85
TFE_NewContextOptionsFunction · 0.85
TFE_NewContextFunction · 0.85
TFE_DeleteContextOptionsFunction · 0.85
TF_GetCodeFunction · 0.85
TF_MessageFunction · 0.85
TestMatrixTensorHandleFunction · 0.85
TF_SetStatusFunction · 0.85

Tested by

no test coverage detected