From 0d1f2d0bcc1687699e65688d6c1ab7efc24bfe52 Mon Sep 17 00:00:00 2001 From: Anthony Platanios Date: Mon, 28 Aug 2017 16:44:15 -0400 Subject: [PATCH] Reverted some of the changes. --- tensorflow/c/eager/c_api.cc | 9 ++++++++- tensorflow/c/eager/c_api.h | 2 +- tensorflow/python/eager/pywrap_tfe_src.cc | 9 +-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tensorflow/c/eager/c_api.cc b/tensorflow/c/eager/c_api.cc index e70539ceefa..75271b6e826 100644 --- a/tensorflow/c/eager/c_api.cc +++ b/tensorflow/c/eager/c_api.cc @@ -537,7 +537,14 @@ void TFE_ContextAddFunctionDef(TFE_Context* ctx, } // extern "C" TFE_TensorHandle* TFE_NewTensorHandle(const tensorflow::Tensor& t) { - return new TFE_TensorHandle(t, nullptr); + TF_Status* status = TF_NewStatus(); + TFE_TensorHandle* tensor = TFE_NewTensorHandle(t, status); + if (TF_GetCode(status) != TF_OK) { + TF_DeleteStatus(status); + return nullptr; + } + TF_DeleteStatus(status); + return tensor; } const tensorflow::Tensor* TFE_TensorHandleUnderlyingTensorInHostMemory( diff --git a/tensorflow/c/eager/c_api.h b/tensorflow/c/eager/c_api.h index 24a80a8f5b5..88a0dd343f2 100644 --- a/tensorflow/c/eager/c_api.h +++ b/tensorflow/c/eager/c_api.h @@ -153,7 +153,7 @@ class Tensor; const tensorflow::Tensor* TFE_TensorHandleUnderlyingTensorInHostMemory( TFE_TensorHandle* h, TF_Status* status); -TFE_TensorHandle* TFE_NewTensorHandle(const tensorflow::Tensor& t, TF_Status* status); +TFE_TensorHandle* TFE_NewTensorHandle(const tensorflow::Tensor& t); #endif #endif // TENSORFLOW_C_EAGER_C_API_H_ diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc index 311bbc9477c..655e3ec8491 100644 --- a/tensorflow/python/eager/pywrap_tfe_src.cc +++ b/tensorflow/python/eager/pywrap_tfe_src.cc @@ -347,14 +347,7 @@ TFE_TensorHandle* TFE_Py_NumpyToTensorHandle(PyObject* obj) { tensorflow::Tensor t; auto cppstatus = tensorflow::NdarrayToTensor(obj, &t); if (cppstatus.ok()) { - TF_Status* status = TF_NewStatus(); - TFE_TensorHandle* tensor = TFE_NewTensorHandle(t, status); - if (TF_GetCode(status) != TF_OK) { - TF_DeleteStatus(status); - return nullptr; - } - TF_DeleteStatus(status); - return tensor; + return TFE_NewTensorHandle(t); } else { tensorflow::mutex_lock l(exception_class_mutex); auto msg = tensorflow::strings::StrCat(