MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TFE_CreateContextFromSession

Function TFE_CreateContextFromSession

tensorflow/c/c_api_experimental.cc:314–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312}
313
314TFE_Context* TFE_CreateContextFromSession(TF_Session* session,
315 TF_Status* status) {
316 auto* opts = TFE_NewContextOptions();
317
318 // Reduce GPU memory allocation, and set appropriate config options for TFE
319 // context.
320 auto* config = TF_CreateConfig(
321 /*xla*/ false, /* gpu_memory_allow_growth */ true, /* num_cpu_devices */
322 10);
323 TFE_ContextOptionsSetConfig(opts, config->data, config->length, status);
324 if (!status->status.ok()) {
325 CHECK(!config);
326 TFE_DeleteContextOptions(opts);
327 return nullptr;
328 }
329
330 auto* ctx = TFE_NewContextFromSession(opts, session, status);
331 TF_DeleteBuffer(config);
332 TFE_DeleteContextOptions(opts);
333 return ctx;
334}
335
336// TODO: retrieve the device string via TFE_ContextListDevices()
337static const char DEFAULT_CPU_DEVICE[] =

Callers 4

TFE_DequeueNamedTensorFunction · 0.85
TFE_EnqueueNamedTensorFunction · 0.85
TFE_EnqueueVariantTensorFunction · 0.85
TFE_DequeueVariantTensorFunction · 0.85

Calls 7

TFE_NewContextOptionsFunction · 0.85
TF_CreateConfigFunction · 0.85
TFE_DeleteContextOptionsFunction · 0.85
TF_DeleteBufferFunction · 0.85
okMethod · 0.45

Tested by

no test coverage detected