"//tensorflow/c:c_api",
"//tensorflow/c:c_api_internal",
"//tensorflow/core:core_cpu_lib",
+ "//tensorflow/core:framework",
"//tensorflow/core:framework_internal",
"//tensorflow/core:framework_lite",
"//tensorflow/core:lib_internal",
return nullptr;
}
- TFE_Context* ret = new TFE_Context(session);
- ret->policy = opts->policy;
- ret->pflr.reset(new tensorflow::ProcessFunctionLibraryRuntime(
- ret->session->device_mgr, opts->session_options.options.env,
- TF_GRAPH_DEF_VERSION, &ret->func_lib_def, {}));
- ret->rendezvous =
- new tensorflow::IntraProcessRendezvous(ret->session->device_mgr);
-
- return ret;
+ return new TFE_Context(*opts, session);
}
void TFE_DeleteContext(TFE_Context* ctx, TF_Status* status) {
#include "tensorflow/core/lib/gtl/stl_util.h"
#include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/thread_annotations.h"
+#include "tensorflow/core/public/version.h"
struct TFE_ContextOptions {
TF_SessionOptions session_options;
};
struct TFE_Context {
- explicit TFE_Context(TF_Session* s) : session(s) {}
+ explicit TFE_Context(const TFE_ContextOptions& opts, TF_Session* s)
+ : policy(opts.policy),
+ session(s),
+ rendezvous(new tensorflow::IntraProcessRendezvous(s->device_mgr)),
+ pflr(new tensorflow::ProcessFunctionLibraryRuntime(
+ session->device_mgr, opts.session_options.options.env,
+ TF_GRAPH_DEF_VERSION, &func_lib_def, {})) {}
- TFE_ContextDevicePlacementPolicy policy;
+ const TFE_ContextDevicePlacementPolicy policy;
// Note: we cannot use C++11 thread_local here as there is no concept of a
// thread-local-object-local variable in C++11.
thread_local_policies GUARDED_BY(policy_map_mu);
// TFE_Context is an extension of TF_Session. And TF_Session needs a TF_Graph.
- TF_Session* session;
- tensorflow::Rendezvous* rendezvous;
+ TF_Session* const session;
+ tensorflow::Rendezvous* const rendezvous;
tensorflow::mutex functions_mu;
tensorflow::FunctionLibraryDefinition func_lib_def GUARDED_BY(functions_mu){
// One FunctionLibraryRuntime per device.
// func_libs[i] is the FunctionLibraryRuntime corresponding to
// session->devices[i].
- std::unique_ptr<tensorflow::ProcessFunctionLibraryRuntime> pflr;
+ const std::unique_ptr<tensorflow::ProcessFunctionLibraryRuntime> pflr;
tensorflow::mutex cache_mu;
std::unordered_map<tensorflow::Fprint128, tensorflow::KernelAndDevice*,
tensorflow::Fprint128Hasher>
kernel_cache GUARDED_BY(cache_mu);
- tensorflow::FunctionLibraryRuntime* func_lib(tensorflow::Device* d) {
+ tensorflow::FunctionLibraryRuntime* func_lib(tensorflow::Device* d) const {
return pflr->GetFLR(d->name());
}