aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/c/c_api.h
diff options
context:
space:
mode:
authorGravatar Skye Wanderman-Milne <skyewm@google.com>2018-03-30 14:56:08 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-30 14:58:45 -0700
commit97731cb122f53552bd15351e046a256f78cca444 (patch)
treedbec22e40bc41f690953b7aad5498516cf457908 /tensorflow/c/c_api.h
parent15c10899c9c0e1717251b380330cc248b2c76c9c (diff)
Raise exception in SWIG on bad TF_Status from C API.
This change provides an alternative mechanism to tf.raise_exception_on_not_ok_status(), which is inefficient and error-prone (people often use the status multiple times in the with block, but it's only checked when the context manager exits). Instead, it uses SWIG to automatically raise an exception when a C API method fails. Note that this removes the status argument from affected methods. For now, I've only applied this typemap to C API methods. It would be good to expand this to all uses of raise_exception_on_not_ok_status. PiperOrigin-RevId: 191121016
Diffstat (limited to 'tensorflow/c/c_api.h')
-rw-r--r--tensorflow/c/c_api.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/tensorflow/c/c_api.h b/tensorflow/c/c_api.h
index b32f574628..fe85f8ee0e 100644
--- a/tensorflow/c/c_api.h
+++ b/tensorflow/c/c_api.h
@@ -1496,7 +1496,8 @@ TF_CAPI_EXPORT extern int TF_DeviceListCount(const TF_DeviceList* list);
// If index is out of bounds, an error code will be set in the status object,
// and a null pointer will be returned.
TF_CAPI_EXPORT extern const char* TF_DeviceListName(const TF_DeviceList* list,
- int index, TF_Status*);
+ int index,
+ TF_Status* status);
// Retrieves the type of the device at the given index.
//
@@ -1506,14 +1507,15 @@ TF_CAPI_EXPORT extern const char* TF_DeviceListName(const TF_DeviceList* list,
// If index is out of bounds, an error code will be set in the status object,
// and a null pointer will be returned.
TF_CAPI_EXPORT extern const char* TF_DeviceListType(const TF_DeviceList* list,
- int index, TF_Status*);
+ int index,
+ TF_Status* status);
// Retrieve the amount of memory associated with a given device.
//
// If index is out of bounds, an error code will be set in the status object,
// and -1 will be returned.
TF_CAPI_EXPORT extern int64_t TF_DeviceListMemoryBytes(
- const TF_DeviceList* list, int index, TF_Status*);
+ const TF_DeviceList* list, int index, TF_Status* status);
// --------------------------------------------------------------------------
// Load plugins containing custom ops and kernels