XIR includes the Op, Tensor, Graph, and Subgraph libraries, which provide a clear and flexible representation of the computational graph. XIR has in-memory and file formats for different uses. The in-memory format XIR is a graph object and the file format is an XMODEL. A graph object can be serialized to an XMODEL while an XMODEL can be deserialized to a graph object.
In the Op library, there is a well-defined set of operators to cover the popular deep learning frameworks, for example, TensorFlow, PyTorch and Caffe1, and all of the built-in DPU operators. This enhances the expression ability and achieves one of the core goals: eliminating the difference between these frameworks and providing a unified representation for users and developers.
XIR also offers Python APIs called PyXIR, empowering you to fully access XIR within your Python environment. With PyXIR, you can co-develop and integrate Python projects with the existing XIR-based tools. This integration eliminates the need for extensive effort to bridge the gap between different languages.
xir::Graph
Graph is the core component of the XIR. It obtains serveral significant APIs,
for example, the xir::Graph::serialize
, xir::Graph::deserialize
and xir::Graph::topological_sort
.
The Graph is like a container, which maintains the Op as its vertex, and uses the producer-consumer relation as the edge.
xir::Op
Op in XIR is the instance of the operator definition either in XIR or extended from XIR. All Op instances can only be created or added by the Graph according to the predefined built-in/extended op definition library. The Op definition mainly includes the input arguments and intrinsic attributes.
Besides the intrinsic predefined attributes, an Op instance is also able to
carry more extrinsic attributes by applying xir::Op::set_attr
API. Each Op instance can only obtain one output
tensor, but more than one fanout ops.
xir::Tensor
Tensor is another important class in XIR. Unlike other frameworks' tensor definitions, XIR's Tensor only describes the data block it represents. The actual data block is excluded from the Tensor.
The key attributes of Tensor are the data type and shape.
xir::Subgraph
XIR's Subgraph is a tree-like hierarchy, which divides a set of ops into several non-overlapping sets. The Graph's entire op set can be seen as the root. The Subgraph can be nested but it must be non-overlapping. The nested insiders must be the children of the outer ones.