diff options
author | Alexandre Passos <apassos@google.com> | 2017-04-12 15:30:57 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-04-12 16:45:16 -0700 |
commit | a5a8558feb9417359e30a991ab5e01cf17194473 (patch) | |
tree | 042d5208bd75c71ac298d0d508eca25dc96b4f7e /tensorflow/c/c_api_test.cc | |
parent | eec34a104fae837a3ea7ce64c8110c2e19f20a27 (diff) |
Fetch / py_func arguments no longer copy.
Change: 153003331
Diffstat (limited to 'tensorflow/c/c_api_test.cc')
-rw-r--r-- | tensorflow/c/c_api_test.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tensorflow/c/c_api_test.cc b/tensorflow/c/c_api_test.cc index 5673f657d3..32143f4f2f 100644 --- a/tensorflow/c/c_api_test.cc +++ b/tensorflow/c/c_api_test.cc @@ -105,6 +105,22 @@ TEST(CAPI, AllocateTensor) { TF_DeleteTensor(t); } +TEST(CAPI, MaybeMove) { + const int num_bytes = 6 * sizeof(float); + float* values = + reinterpret_cast<float*>(tensorflow::cpu_allocator()->AllocateRaw( + EIGEN_MAX_ALIGN_BYTES, num_bytes)); + int64_t dims[] = {2, 3}; + bool deallocator_called = false; + TF_Tensor* t = TF_NewTensor(TF_FLOAT, dims, 2, values, num_bytes, + &Deallocator, &deallocator_called); + + TF_Tensor* o = TF_TensorMaybeMove(t); + ASSERT_TRUE(o == nullptr); // It is unsafe to move memory TF might not own. + TF_DeleteTensor(t); + EXPECT_TRUE(deallocator_called); +} + TEST(CAPI, LibraryLoadFunctions) { // Load the library. TF_Status* status = TF_NewStatus(); |