Session

Undocumented in source.

Constructors

this
this(TF_Graph* graph, TF_Status* s, bool useXLA)

Constructs a new session.

Destructor

~this
~this()
Undocumented in source.

Alias This

session_

Members

Functions

CloseAndDelete
void CloseAndDelete(TF_Status* s)

Closes and deletes input/output values explicitly.

DeleteInputValues
void DeleteInputValues()
Undocumented in source. Be warned that the author may not have intended to support it.
ResetOutputValues
void ResetOutputValues()
Undocumented in source. Be warned that the author may not have intended to support it.
Run
void Run(TF_Status* s)
Undocumented in source. Be warned that the author may not have intended to support it.
SetInputs
void SetInputs(TF_Tensor*[TF_Operation*] inputs)

Sets input values.

SetOutputs
void SetOutputs(TF_Operation*[N] outputs)

Sets output values.

Variables

input_values_
Array!(TF_Tensor*) input_values_;
Undocumented in source.
inputs_
Array!TF_Output inputs_;
Undocumented in source.
output_values_
Array!(TF_Tensor*) output_values_;
Undocumented in source.
outputs_
Array!TF_Output outputs_;
Undocumented in source.
session_
TF_Session* session_;
Undocumented in source.
targets_
Array!(TF_Operation*) targets_;
Undocumented in source.

Examples

CAPI Session test in tensorflow/c/c_api_test.c

TF_Status* s = TF_NewStatus();
TF_Graph* graph = TF_NewGraph();

// Make a placeholder operation.
TF_Operation* feed = Placeholder(graph, s);
assertStatus(s);

// Make a constant operation with the scalar "2".
TF_Operation* two = ScalarConst(2, graph, s);
assertStatus(s);

// Add operation.
TF_Operation* add = Add(feed, two, graph, s);
assertStatus(s);

// Create a session for this graph.
auto session = Session(graph, s);
assertStatus(s);

// Run the graph.
import std.typecons : tuple;
session.SetInputs([feed: makeTensor(3)]);
session.SetOutputs(add);
session.Run(s);
assertStatus(s);
TF_Tensor* result = session.output_values_[0];
assert(result !is null);
assert(TF_TensorType(result) == TF_INT32);
int* resultVal = cast(int*) TF_TensorData(result);
assert(2 + 3 == *resultVal);

Meta