Creating a GraphTensor
To get started, you can create aGraphTensor by initializing a graph and adding tensor nodes:
Graph::new()initializes a new computational graph.GraphTensor<R1<3>>represents a tensor node with metadata about its shape (in this case, rank-1 with size 3).
Performing Operations with GraphTensors
Once you have createdGraphTensors, you can perform various linear algebra operations, similar to libraries like PyTorch:
b + a do not consume the original tensors (a and b).
Both remain available for reuse in subsequent operations. This is made possible because GraphTensor is a lightweight tracking structure that implements the Copy trait.
This design allows operations on GraphTensor to construct a computational graph without immediate execution, so no values are assigned to the GraphTensor at this stage.
Actual computations are postponed until cx.gen_trace() is invoked, which enables the compiler to optimize the execution process effectively.
For more details on how to build, run, and prove graphs, check out this guide.