How to make graphs
There are 3 class templates that can be used These class templates will provide operations that can be executed after compilation of the graph
- generate
member functions of this class template will generate tensors
- operate
member functions of this class will receive tensors from other operations, and return the result as a single tensor
- final
member functions of this class will receive tensors from other operations, *and will not return any. every tensor should be connected to this final *operation to be executed
There are several rules that must be kept 1. Tensors must be generated by methods of 'generate' template class 2. Every tensor should be connected to 'final' operation (otherwise, they won't be executed)
Here is the example code (you will find some more examples at Tests/UnitTests/SimpleTest.cpp)
/// file stream class template is used for streaming data inside external
/// files
file_stream<int> file_stream;
/// operation that streams file data into tensor in shape (2,2,1)
auto input_tensor1 =
generate<int>::placeholder(tensor_shape(2, 2, 1), file_stream);
/// operation that returns tensor variable in shape (2, 2, 1), and mark it
/// trainable(non- constant)
auto input_tensor2 =
generate<int>::variable(tensor_shape(2, 2, 1), true);
/// operation that multiplies two tensors and returns tensor to contain the
/// result
auto multiplied_tensor1 =
operate<int>::mat_mul(input_tensor2, input_tensor1);
/// operation that receives tensor and marks given tensor has no more
/// further operation (end of the graph)
final<int>::wrapper(multiplied_tensor1);