From bdab0b3c111bbe1c9656fa2228f1a4d28df5a7bf Mon Sep 17 00:00:00 2001 From: Mingsheng Hong Date: Thu, 27 Sep 2018 15:32:38 -0700 Subject: Added an experimental API for user to set an internal error status. See https://github.com/apple/swift/pull/19588/files#diff-923cd5ac82727b31d446c23641b3d749 for an example usage. Also removed an experimental API that's no longer needed. PiperOrigin-RevId: 214847132 --- tensorflow/c/c_api_experimental.cc | 34 +++------------------------------- tensorflow/c/c_api_experimental.h | 6 ++---- 2 files changed, 5 insertions(+), 35 deletions(-) (limited to 'tensorflow/c') diff --git a/tensorflow/c/c_api_experimental.cc b/tensorflow/c/c_api_experimental.cc index f316e4ba67..d4b78138e9 100644 --- a/tensorflow/c/c_api_experimental.cc +++ b/tensorflow/c/c_api_experimental.cc @@ -8738,35 +8738,7 @@ void TFE_TensorHandlePrintDebugString(TFE_TensorHandle* handle) { TF_DeleteStatus(status); } -TFE_TensorHandle* TFE_RunConstOp(TFE_Context* ctx) { - // Intentionally LOG into INFO below for ease of debugging. - VLOG(1) << "TFE_RunConstOp called"; - - auto* status = TF_NewStatus(); - auto* op = TFE_NewOp(ctx, "Const", status); - CheckOk(status); - TFE_OpSetAttrType(op, "dtype", TF_FLOAT); - - auto* tensor = - TF_AllocateTensor(TF_FLOAT, /*shape.data()*/ nullptr, /*shape.size()*/ 0, - TF_DataTypeSize(TF_FLOAT) * 1); - auto* ptr = reinterpret_cast(TF_TensorData(tensor)); - *reinterpret_cast(ptr) = 17.0; - - TFE_OpSetAttrTensor(op, "value", tensor, status); - CheckOk(status); - TF_DeleteTensor(tensor); - VLOG(1) << "New op created"; - - TFE_TensorHandle* retval; - int num_retvals = 1; - TFE_Execute(op, &retval, &num_retvals, status); - CheckOk(status); - CHECK_EQ(num_retvals, 1); - VLOG(1) << "Op executed"; - - TFE_DeleteOp(op); - TF_DeleteStatus(status); - - return retval; +TF_CAPI_EXPORT extern void TF_MakeInternalErrorStatus(TF_Status* status, + const char* errMsg) { + status->status = tensorflow::errors::Internal(errMsg); } diff --git a/tensorflow/c/c_api_experimental.h b/tensorflow/c/c_api_experimental.h index 950ad9aeed..d98d532e32 100644 --- a/tensorflow/c/c_api_experimental.h +++ b/tensorflow/c/c_api_experimental.h @@ -180,10 +180,8 @@ TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_DequeueVariantTensor( TF_CAPI_EXPORT extern void TFE_TensorHandlePrintDebugString( TFE_TensorHandle* handle); -// Returns a const scalar tensor. -// Caller owns both the input and the output tensor handles. -// TODO: Remove this API with hard-coded tensor computation. -TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_RunConstOp(TFE_Context* ctx); +TF_CAPI_EXPORT extern void TF_MakeInternalErrorStatus(TF_Status* status, + const char* errMsg); #ifdef __cplusplus } /* end extern "C" */ -- cgit v1.2.3