public BaseSession(string target = "", Graph g = null, SessionOptions opts = null) { _graph = g is null?ops.get_default_graph() : g; _graph.as_default(); _target = UTF8Encoding.UTF8.GetBytes(target); SessionOptions newOpts = null; if (opts == null) { newOpts = new SessionOptions(); } var status = new Status(); _handle = c_api.TF_NewSession(_graph, opts ?? newOpts, status); // dispose newOpts if (opts == null) { c_api.TF_DeleteSessionOptions(newOpts); } status.Check(true); }
public BaseSession(string target = "", Graph g = null, SessionOptions opts = null, Status status = null) { _graph = g ?? ops.get_default_graph(); _graph.as_default(); _target = Encoding.UTF8.GetBytes(target); SessionOptions lopts = opts ?? new SessionOptions(); lock (Locks.ProcessWide) { status = status ?? new Status(); _handle = c_api.TF_NewSession(_graph, opts ?? lopts, status); status.Check(true); } }
public BaseSession(string target = "", Graph g = null, ConfigProto config = null, Status status = null) { _graph = g ?? ops.get_default_graph(); _graph.as_default(); _target = Encoding.UTF8.GetBytes(target); using (var opts = new SessionOptions(target, config)) { lock (Locks.ProcessWide) { status = status ?? new Status(); _handle = c_api.TF_NewSession(_graph, opts.Handle, status.Handle); status.Check(true); } } }
public BaseSession(string target = "", Graph g = null, ConfigProto config = null, Status status = null) { _graph = g ?? ops.get_default_graph(); if (!_graph.building_function) { if (ops.get_default_graph() != _graph) { _graph.as_default(); } } using var opts = new SessionOptions(target, config); status = status ?? tf.Status; _handle = c_api.TF_NewSession(_graph, opts.Handle, status.Handle); status.Check(true); }
public void __enter__() { // If the default graph is building a function, then we should not replace it // with the cached graph. if (ops.get_default_graph().building_function) { _building_function = true; } else { _building_function = false; } if (_in_graph_mode && !_building_function) { _graph.as_default(); } _scope = _enter_scope_uncached(); }