1 /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 #ifndef TENSORFLOW_C_EAGER_C_API_EXPERIMENTAL_H_ 16 #define TENSORFLOW_C_EAGER_C_API_EXPERIMENTAL_H_ 17 18 #include "tensorflow/c/c_api.h" 19 #include "tensorflow/c/eager/c_api.h" 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 // Resets `op_to_reset` with `op_or_function_name` and `raw_device_name`. This 26 // is for performance optimization by reusing an exiting unused op rather than 27 // creating a new op every time. If `raw_device_name` is `NULL` or empty, it 28 // does not set the device name. If it's not `NULL`, then it attempts to parse 29 // and set the device name. It's effectively `TFE_OpSetDevice`, but it is faster 30 // than seperately calling it because if the existing op has the same 31 // `raw_device_name`, it skips parsing and just leave as it is. 32 TF_CAPI_EXPORT extern void TFE_OpReset(TFE_Op* op_to_reset, 33 const char* op_or_function_name, 34 const char* raw_device_name, 35 TF_Status* status); 36 37 TF_CAPI_EXPORT extern void TFE_OpConsumeInput(TFE_Op* op, TFE_TensorHandle* h, 38 TF_Status* status); 39 40 // A profiler which will start profiling when creating the object and will stop 41 // when the object is destroyed. It will profile all operations run under the 42 // given TFE_Context. Multiple instance of it can be created, but at most one 43 // of them will profile for each TFE_Context. 44 // Thread-safety: TFE_Profiler is thread-safe. 45 typedef struct TFE_Profiler TFE_Profiler; 46 47 TF_CAPI_EXPORT extern TFE_Profiler* TFE_NewProfiler(); 48 TF_CAPI_EXPORT extern bool TFE_ProfilerIsOk(TFE_Profiler* profiler); 49 TF_CAPI_EXPORT extern void TFE_DeleteProfiler(TFE_Profiler* profiler); 50 51 // The output string is a binary string of tensorflow.tpu.Trace. User can write 52 // the string to file for offline analysis by tensorboard. 53 TF_CAPI_EXPORT extern void TFE_ProfilerSerializeToString(TFE_Profiler* profiler, 54 TF_Buffer* buf, 55 TF_Status* status); 56 57 // Start a profiler grpc server which listens to specified port. It will start 58 // the server on its own thread. It can be shutdown by terminating tensorflow. 59 // It can be used in both Eager mode and graph mode. Creating multiple profiler 60 // server is allowed. The service defined in 61 // tensorflow/contrib/tpu/profiler/tpu_profiler.proto. Please use 62 // tensorflow/contrib/tpu/profiler/capture_tpu_profile to capture trace file 63 // following https://cloud.google.com/tpu/docs/cloud-tpu-tools#capture_trace. 64 TF_CAPI_EXPORT extern void TFE_StartProfilerServer(int port); 65 66 // Enables only graph collection in RunMetadata on the functions executed from 67 // this context. 68 TF_CAPI_EXPORT extern void TFE_ContextEnableGraphCollection(TFE_Context* ctx); 69 70 // Disables only graph collection in RunMetadata on the functions executed from 71 // this context. 72 TF_CAPI_EXPORT extern void TFE_ContextDisableGraphCollection(TFE_Context* ctx); 73 74 // Send a grpc request to profiler server (service_addr) to perform on-demand 75 // profiling and save the result into logdir which can be visualized by 76 // TensorBoard. worker_list is the list of worker TPUs separated by ','. Set 77 // include_dataset_opts to false to profile longer traces. It will block the 78 // caller thread until receives tracing result. 79 // This API is designed for TensorBoard, for end user, please use 80 // tensorflow/contrib/tpu/profiler/capture_tpu_profile instead following 81 // https://cloud.google.com/tpu/docs/cloud-tpu-tools#capture_trace. 82 TF_CAPI_EXPORT extern bool TFE_ProfilerClientStartTracing( 83 const char* service_addr, const char* logdir, const char* worker_list, 84 bool include_dataset_ops, int duration_ms, int num_tracing_attempts, 85 TF_Status* status); 86 87 // Send a grpc request to profiler server (service_addr) to perform on-demand 88 // monitoring and return the result in a string. It will block the 89 // caller thread until receiving the monitoring result. 90 // This API is designed for TensorBoard, for end user, please use 91 // tensorflow/contrib/tpu/profiler/capture_tpu_profile instead following 92 // https://cloud.google.com/tpu/docs/cloud-tpu-tools#capture_trace. 93 TF_CAPI_EXPORT extern void TFE_ProfilerClientMonitor( 94 const char* service_addr, int duration_ms, int monitoring_level, 95 bool display_timestamp, TF_Buffer* result, TF_Status* status); 96 97 // TODO(fishx): Move these monitoring APIs into a separate file. 98 // ----------------------------------------------------------------------------- 99 // Monitoring Counter APIs. 100 // These APIs de-templated monitoring Counter for swig. 101 102 typedef struct TFE_MonitoringCounterCell TFE_MonitoringCounterCell; 103 104 // Atomically increments the value of the cell. The value must be non-negative. 105 TF_CAPI_EXPORT extern void TFE_MonitoringCounterCellIncrementBy( 106 TFE_MonitoringCounterCell* cell, int64_t value); 107 108 // Retrieves the current value of the cell. 109 TF_CAPI_EXPORT extern int64_t TFE_MonitoringCounterCellValue( 110 TFE_MonitoringCounterCell* cell); 111 112 // APIs for Counter without label. 113 typedef struct TFE_MonitoringCounter0 TFE_MonitoringCounter0; 114 // Returns a new Counter metric object. The caller should manage lifetime of 115 // the object. Using duplicate metric name will crash the program with fatal 116 // error. 117 TF_CAPI_EXPORT extern TFE_MonitoringCounter0* TFE_MonitoringNewCounter0( 118 const char* name, TF_Status* status, const char* description); 119 // Deletes the Counter object. 120 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteCounter0( 121 TFE_MonitoringCounter0* counter); 122 // Retrieves the cell from the Counter object. The Counter object will manage 123 // lifetime of the cell. 124 TF_CAPI_EXPORT extern TFE_MonitoringCounterCell* TFE_MonitoringGetCellCounter0( 125 TFE_MonitoringCounter0* counter); 126 127 // APIs for Counter with 1 label. 128 typedef struct TFE_MonitoringCounter1 TFE_MonitoringCounter1; 129 TF_CAPI_EXPORT extern TFE_MonitoringCounter1* TFE_MonitoringNewCounter1( 130 const char* name, TF_Status* status, const char* description, 131 const char* label1); 132 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteCounter1( 133 TFE_MonitoringCounter1* counter); 134 TF_CAPI_EXPORT extern TFE_MonitoringCounterCell* TFE_MonitoringGetCellCounter1( 135 TFE_MonitoringCounter1* counter, const char* label1); 136 137 // APIs for Counter with 2 labels. 138 typedef struct TFE_MonitoringCounter2 TFE_MonitoringCounter2; 139 TF_CAPI_EXPORT extern TFE_MonitoringCounter2* TFE_MonitoringNewCounter2( 140 const char* name, TF_Status* status, const char* description, 141 const char* label1, const char* label2); 142 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteCounter2( 143 TFE_MonitoringCounter2* counter); 144 TF_CAPI_EXPORT extern TFE_MonitoringCounterCell* TFE_MonitoringGetCellCounter2( 145 TFE_MonitoringCounter2* counter, const char* label1, const char* label2); 146 147 // ----------------------------------------------------------------------------- 148 // Monitoring Gauge APIs. 149 // These APIs de-templated monitoring Gauge for swig. 150 151 typedef struct TFE_MonitoringIntGaugeCell TFE_MonitoringIntGaugeCell; 152 153 // Atomically set the value of the cell. 154 TF_CAPI_EXPORT extern void TFE_MonitoringIntGaugeCellSet( 155 TFE_MonitoringIntGaugeCell* cell, int64_t value); 156 157 // Retrieves the current value of the cell. 158 TF_CAPI_EXPORT extern int64_t TFE_MonitoringIntGaugeCellValue( 159 TFE_MonitoringIntGaugeCell* cell); 160 161 // APIs for Int Gauge without label. 162 typedef struct TFE_MonitoringIntGauge0 TFE_MonitoringIntGauge0; 163 TF_CAPI_EXPORT extern TFE_MonitoringIntGauge0* TFE_MonitoringNewIntGauge0( 164 const char* name, TF_Status* out_status, const char* description); 165 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteIntGauge0( 166 TFE_MonitoringIntGauge0* gauge); 167 TF_CAPI_EXPORT extern TFE_MonitoringIntGaugeCell* 168 TFE_MonitoringGetCellIntGauge0(TFE_MonitoringIntGauge0* gauge); 169 170 // APIs for Int Gauge with 1 label. 171 typedef struct TFE_MonitoringIntGauge1 TFE_MonitoringIntGauge1; 172 TF_CAPI_EXPORT extern TFE_MonitoringIntGauge1* TFE_MonitoringNewIntGauge1( 173 const char* name, TF_Status* out_status, const char* description, 174 const char* label1); 175 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteIntGauge1( 176 TFE_MonitoringIntGauge1* gauge); 177 TF_CAPI_EXPORT extern TFE_MonitoringIntGaugeCell* 178 TFE_MonitoringGetCellIntGauge1(TFE_MonitoringIntGauge1* gauge, 179 const char* label1); 180 181 // APIs for Int Gauge with 2 label. 182 typedef struct TFE_MonitoringIntGauge2 TFE_MonitoringIntGauge2; 183 TF_CAPI_EXPORT extern TFE_MonitoringIntGauge2* TFE_MonitoringNewIntGauge2( 184 const char* name, TF_Status* out_status, const char* description, 185 const char* label1, const char* label2); 186 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteIntGauge2( 187 TFE_MonitoringIntGauge2* gauge); 188 TF_CAPI_EXPORT extern TFE_MonitoringIntGaugeCell* 189 TFE_MonitoringGetCellIntGauge2(TFE_MonitoringIntGauge2* gauge, 190 const char* label1, const char* label2); 191 192 typedef struct TFE_MonitoringStringGaugeCell TFE_MonitoringStringGaugeCell; 193 TF_CAPI_EXPORT extern void TFE_MonitoringStringGaugeCellSet( 194 TFE_MonitoringStringGaugeCell* cell, const char* value); 195 // Retrieves the string value and saves it in buffer. 196 TF_CAPI_EXPORT extern const void TFE_MonitoringStringGaugeCellValue( 197 TFE_MonitoringStringGaugeCell* cell, TF_Buffer* buf); 198 199 // APIs for String Gauge without label. 200 typedef struct TFE_MonitoringStringGauge0 TFE_MonitoringStringGauge0; 201 TF_CAPI_EXPORT extern TFE_MonitoringStringGauge0* TFE_MonitoringNewStringGauge0( 202 const char* name, TF_Status* out_status, const char* description); 203 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteStringGauge0( 204 TFE_MonitoringStringGauge0* gauge); 205 TF_CAPI_EXPORT extern TFE_MonitoringStringGaugeCell* 206 TFE_MonitoringGetCellStringGauge0(TFE_MonitoringStringGauge0* gauge); 207 208 // APIs for String Gauge with 1 label. 209 typedef struct TFE_MonitoringStringGauge1 TFE_MonitoringStringGauge1; 210 TF_CAPI_EXPORT extern TFE_MonitoringStringGauge1* TFE_MonitoringNewStringGauge1( 211 const char* name, TF_Status* out_status, const char* description, 212 const char* label1); 213 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteStringGauge1( 214 TFE_MonitoringStringGauge1* gauge); 215 TF_CAPI_EXPORT extern TFE_MonitoringStringGaugeCell* 216 TFE_MonitoringGetCellStringGauge1(TFE_MonitoringStringGauge1* gauge, 217 const char* label1); 218 219 // APIs for String Gauge with 2 label. 220 typedef struct TFE_MonitoringStringGauge2 TFE_MonitoringStringGauge2; 221 TF_CAPI_EXPORT extern TFE_MonitoringStringGauge2* TFE_MonitoringNewStringGauge2( 222 const char* name, TF_Status* out_status, const char* description, 223 const char* label1, const char* label2); 224 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteStringGauge2( 225 TFE_MonitoringStringGauge2* gauge); 226 TF_CAPI_EXPORT extern TFE_MonitoringStringGaugeCell* 227 TFE_MonitoringGetCellStringGauge2(TFE_MonitoringStringGauge2* gauge, 228 const char* label1, const char* label2); 229 230 typedef struct TFE_MonitoringBoolGaugeCell TFE_MonitoringBoolGaugeCell; 231 TF_CAPI_EXPORT extern void TFE_MonitoringBoolGaugeCellSet( 232 TFE_MonitoringBoolGaugeCell* cell, bool value); 233 TF_CAPI_EXPORT extern bool TFE_MonitoringBoolGaugeCellValue( 234 TFE_MonitoringBoolGaugeCell* cell); 235 236 // APIs for Bool Gauge without label. 237 typedef struct TFE_MonitoringBoolGauge0 TFE_MonitoringBoolGauge0; 238 TF_CAPI_EXPORT extern TFE_MonitoringBoolGauge0* TFE_MonitoringNewBoolGauge0( 239 const char* name, TF_Status* out_status, const char* description); 240 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteBoolGauge0( 241 TFE_MonitoringBoolGauge0* gauge); 242 TF_CAPI_EXPORT extern TFE_MonitoringBoolGaugeCell* 243 TFE_MonitoringGetCellBoolGauge0(TFE_MonitoringBoolGauge0* gauge); 244 245 // APIs for Bool Gauge with 1 label. 246 typedef struct TFE_MonitoringBoolGauge1 TFE_MonitoringBoolGauge1; 247 TF_CAPI_EXPORT extern TFE_MonitoringBoolGauge1* TFE_MonitoringNewBoolGauge1( 248 const char* name, TF_Status* out_status, const char* description, 249 const char* label1); 250 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteBoolGauge1( 251 TFE_MonitoringBoolGauge1* gauge); 252 TF_CAPI_EXPORT extern TFE_MonitoringBoolGaugeCell* 253 TFE_MonitoringGetCellBoolGauge1(TFE_MonitoringBoolGauge1* gauge, 254 const char* label1); 255 256 // APIs for Bool Gauge with 2 label. 257 typedef struct TFE_MonitoringBoolGauge2 TFE_MonitoringBoolGauge2; 258 TF_CAPI_EXPORT extern TFE_MonitoringBoolGauge2* TFE_MonitoringNewBoolGauge2( 259 const char* name, TF_Status* out_status, const char* description, 260 const char* label1, const char* label2); 261 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteBoolGauge2( 262 TFE_MonitoringBoolGauge2* gauge); 263 TF_CAPI_EXPORT extern TFE_MonitoringBoolGaugeCell* 264 TFE_MonitoringGetCellBoolGauge2(TFE_MonitoringBoolGauge2* gauge, 265 const char* label1, const char* label2); 266 267 // ----------------------------------------------------------------------------- 268 // Monitoring Sampler APIs. 269 // These APIs de-templated monitoring Sampler for swig. 270 271 typedef struct TFE_MonitoringSamplerCell TFE_MonitoringSamplerCell; 272 273 // Atomically add the value of the cell. 274 TF_CAPI_EXPORT extern void TFE_MonitoringSamplerCellAdd( 275 TFE_MonitoringSamplerCell* cell, double value); 276 277 // Retrieves the current value of the cell. The return value is a HistogramProto 278 // saved in buffer. 279 TF_CAPI_EXPORT extern void TFE_MonitoringSamplerCellValue( 280 TFE_MonitoringSamplerCell* cell, TF_Buffer* buf); 281 282 // APIs for sampler buckets 283 typedef struct TFE_MonitoringBuckets TFE_MonitoringBuckets; 284 TF_CAPI_EXPORT extern TFE_MonitoringBuckets* 285 TFE_MonitoringNewExponentialBuckets(double scale, double growth_factor, 286 int bucket_count); 287 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteBuckets( 288 TFE_MonitoringBuckets* buckets); 289 290 // APIs for Sampler without label. 291 typedef struct TFE_MonitoringSampler0 TFE_MonitoringSampler0; 292 TF_CAPI_EXPORT extern TFE_MonitoringSampler0* TFE_MonitoringNewSampler0( 293 const char* name, TFE_MonitoringBuckets* buckets, TF_Status* out_status, 294 const char* description); 295 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteSampler0( 296 TFE_MonitoringSampler0* sampler); 297 TF_CAPI_EXPORT extern TFE_MonitoringSamplerCell* TFE_MonitoringGetCellSampler0( 298 TFE_MonitoringSampler0* sampler); 299 300 // APIs for Sampler with 1 label. 301 typedef struct TFE_MonitoringSampler1 TFE_MonitoringSampler1; 302 TF_CAPI_EXPORT extern TFE_MonitoringSampler1* TFE_MonitoringNewSampler1( 303 const char* name, TFE_MonitoringBuckets* buckets, TF_Status* out_status, 304 const char* description, const char* label1); 305 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteSampler1( 306 TFE_MonitoringSampler1* sampler); 307 TF_CAPI_EXPORT extern TFE_MonitoringSamplerCell* TFE_MonitoringGetCellSampler1( 308 TFE_MonitoringSampler1* sampler, const char* label1); 309 310 // APIs for Sampler with 2 label. 311 typedef struct TFE_MonitoringSampler2 TFE_MonitoringSampler2; 312 TF_CAPI_EXPORT extern TFE_MonitoringSampler2* TFE_MonitoringNewSampler2( 313 const char* name, TFE_MonitoringBuckets* buckets, TF_Status* out_status, 314 const char* description, const char* label1, const char* label2); 315 TF_CAPI_EXPORT extern void TFE_MonitoringDeleteSampler2( 316 TFE_MonitoringSampler2* sampler); 317 TF_CAPI_EXPORT extern TFE_MonitoringSamplerCell* TFE_MonitoringGetCellSampler2( 318 TFE_MonitoringSampler2* sampler, const char* label1, const char* label2); 319 320 // LINT.IfChange 321 // Note: Keep in sync with internal copy of enum in eager/context.h. 322 typedef enum TFE_ContextMirroringPolicy { 323 // Do not maintain mirrors in a TensorHandle, instead make new TensorHandle 324 // copies with their own lifetime. 325 TFE_MIRRORING_NONE = 0, 326 // Mirroring any remote tensor handles, associating them with the lifetime of 327 // the local TensorHandle. 328 TFE_MIRRORING_ALL = 1, 329 } TFE_ContextMirroringPolicy; 330 // LINT.ThenChange(//tensorflow/core/common_runtime/eager/context.h) 331 332 TF_CAPI_EXPORT extern void TFE_ContextOptionsSetMirroringPolicy( 333 TFE_ContextOptions*, TFE_ContextMirroringPolicy); 334 335 // Sets a thread-local mirroring policy. After this call, other calls to 336 // TFE_Execute in the same thread will use the mirroring policy specified here 337 // instead of the mirroring policy used to construct the context. This has no 338 // effect on the mirroring policy used by other program threads. 339 TF_CAPI_EXPORT extern void TFE_ContextSetThreadLocalMirroringPolicy( 340 TFE_Context*, TFE_ContextMirroringPolicy); 341 342 // Returns the mirroring policy to be used by this context in the current 343 // thread. 344 TF_CAPI_EXPORT extern TFE_ContextMirroringPolicy TFE_ContextGetMirroringPolicy( 345 TFE_Context*); 346 347 // Sets whether to copy the remote inputs of a function lazily. 348 TF_CAPI_EXPORT extern void TFE_ContextOptionsSetLazyRemoteInputsCopy( 349 TFE_ContextOptions*, bool lazy_copy); 350 351 // ----------------------------------------------------------------------------- 352 // Cancellation APIs. 353 354 typedef struct TFE_CancellationManager TFE_CancellationManager; 355 TF_CAPI_EXPORT extern TFE_CancellationManager* TFE_NewCancellationManager(); 356 TF_CAPI_EXPORT extern bool TFE_CancellationManagerIsCancelled( 357 TFE_CancellationManager*); 358 TF_CAPI_EXPORT extern void TFE_CancellationManagerStartCancel( 359 TFE_CancellationManager*); 360 TF_CAPI_EXPORT extern void TFE_DeleteCancellationManager( 361 TFE_CancellationManager*); 362 363 // Associates the given `cancellation_manager` with `op`, so that invoking 364 // `TFE_CancellationManagerStartCancel(cancellation_manager)` will cancel the 365 // execution of `op`. 366 typedef struct TFE_CancellationManager TFE_CancellationManager; 367 TF_CAPI_EXPORT extern void TFE_OpSetCancellationManager( 368 TFE_Op* op, TFE_CancellationManager* cancellation_manager, 369 TF_Status* status); 370 371 // ----------------------------------------------------------------------------- 372 // Eager Executor APIs. 373 typedef struct TFE_Executor TFE_Executor; 374 375 // Creates a new eager Executor. Nodes in one executor are guaranteed to be 376 // executed in sequence. Assigning nodes to different executors allows executing 377 // nodes in parallel. 378 TF_CAPI_EXPORT extern TFE_Executor* TFE_NewExecutor(bool is_async); 379 380 // Deletes the eager Executor without waiting for enqueued nodes. Please call 381 // TFE_ExecutorWaitForAllPendingNodes before calling this API if you want to 382 // make sure all nodes are finished. 383 TF_CAPI_EXPORT extern void TFE_DeleteExecutor(TFE_Executor*); 384 385 // Returns true if the executor is in async mode. 386 TF_CAPI_EXPORT extern bool TFE_ExecutorIsAsync(TFE_Executor*); 387 388 // Causes the calling thread to block till all ops dispatched in this executor 389 // have been executed. Note that "execution" here refers to kernel execution / 390 // scheduling of copies, etc. Similar to sync execution, it doesn't guarantee 391 // that lower level device queues (like GPU streams) have been flushed. 392 // 393 // This call may not block for execution of ops enqueued concurrently with this 394 // call. 395 TF_CAPI_EXPORT extern void TFE_ExecutorWaitForAllPendingNodes( 396 TFE_Executor*, TF_Status* status); 397 398 // When an error happens, any pending operations are discarded and newly issued 399 // ops return an error. This call clears the error state and re-enables 400 // execution of newly issued ops. 401 // 402 // Note that outputs of discarded ops remain in a corrupt state and should not 403 // be used for future calls. 404 // TODO(agarwal): mark the affected handles and raise errors if they are used. 405 TF_CAPI_EXPORT extern void TFE_ExecutorClearError(TFE_Executor*); 406 407 // Sets a custom Executor for current thread. All nodes created by this thread 408 // will be added to this Executor. It will override current executor. 409 TF_CAPI_EXPORT extern void TFE_ContextSetExecutorForThread(TFE_Context*, 410 TFE_Executor*); 411 412 // Returns the Executor for current thread. 413 TF_CAPI_EXPORT extern TFE_Executor* TFE_ContextGetExecutorForThread( 414 TFE_Context*); 415 416 // ----------------------------------------------------------------------------- 417 // Dynamic cluster API. 418 419 // Update an existing context with a new set of servers defined in a ServerDef 420 // proto. Servers can be added to and removed from the list of remote workers 421 // in the context. New set of servers identified by the ServerDef must be up 422 // when the context is updated. 423 // 424 // This API is for experimental usage and may be subject to change. 425 TF_CAPI_EXPORT extern void TFE_ContextUpdateServerDef(TFE_Context* ctx, 426 int keep_alive_secs, 427 const void* proto, 428 size_t proto_len, 429 TF_Status* status); 430 431 // Checks whether a remote worker is alive or not. This will return true even if 432 // the context doesn't exist on the remote worker. 433 TF_CAPI_EXPORT extern bool TFE_ContextCheckAlive(TFE_Context* ctx, 434 const char* worker_name, 435 TF_Status* status); 436 437 // This function will block till the operation that produces `h` has 438 // completed. This is only valid on local TFE_TensorHandles. The pointer 439 // returned will be on the device in which the TFE_TensorHandle resides (so e.g. 440 // for a GPU tensor this will return a pointer to GPU memory). The pointer is 441 // only guaranteed to be valid until TFE_DeleteTensorHandle is called on this 442 // TensorHandle. Only supports POD data types. 443 TF_CAPI_EXPORT extern void* TFE_TensorHandleDevicePointer(TFE_TensorHandle*, 444 TF_Status*); 445 446 // This function will block till the operation that produces `h` has 447 // completed. This is only valid on local TFE_TensorHandles. Returns the size in 448 // bytes of the memory pointed to by the device pointer returned above. 449 TF_CAPI_EXPORT extern size_t TFE_TensorHandleDeviceMemorySize(TFE_TensorHandle*, 450 TF_Status*); 451 452 // Creates a new TensorHandle from memory residing in device_name. Takes 453 // ownership of the memory, and will call deleter to release it after TF 454 // no longer needs it or in case of error. 455 TF_CAPI_EXPORT extern TFE_TensorHandle* TFE_NewTensorHandleFromDeviceMemory( 456 TFE_Context* ctx, const char* device_name, TF_DataType, const int64_t* dims, 457 int num_dims, void* data, size_t len, 458 void (*deallocator)(void* data, size_t len, void* arg), 459 void* deallocator_arg, TF_Status* status); 460 461 // Retrieves the address space (i.e. job, replia, task) of the local host and 462 // saves it in the buffer. 463 TF_CAPI_EXPORT extern void TFE_HostAddressSpace(TFE_Context* ctx, 464 TF_Buffer* buf); 465 466 #ifdef __cplusplus 467 } /* end extern "C" */ 468 #endif 469 470 #endif // TENSORFLOW_C_EAGER_C_API_EXPERIMENTAL_H_ 471