aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c
diff options
context:
space:
mode:
authorGravatar Mingsheng Hong <hongm@google.com>2018-09-27 15:32:38 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-27 15:40:56 -0700
commitbdab0b3c111bbe1c9656fa2228f1a4d28df5a7bf (patch)
treedecbb27adcafeaadeebbfac3d72774a8397c3042 /tensorflow/c
parenta3291ab1f2cb9ea2c4e4b3b9b26ad1a1866dfc50 (diff)
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
Diffstat (limited to 'tensorflow/c')
-rw-r--r--tensorflow/c/c_api_experimental.cc34
-rw-r--r--tensorflow/c/c_api_experimental.h6
2 files changed, 5 insertions, 35 deletions
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<char*>(TF_TensorData(tensor));
- *reinterpret_cast<float*>(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" */