afe.backends ============ .. py:module:: afe.backends Submodules ---------- .. toctree:: :maxdepth: 1 /pages/api_reference/python-autoapi/afe/backends/apu/index /pages/api_reference/python-autoapi/afe/backends/backend_checker/index /pages/api_reference/python-autoapi/afe/backends/backends/index /pages/api_reference/python-autoapi/afe/backends/checker_utils/index /pages/api_reference/python-autoapi/afe/backends/cpu/index /pages/api_reference/python-autoapi/afe/backends/ev/index /pages/api_reference/python-autoapi/afe/backends/mla/index /pages/api_reference/python-autoapi/afe/backends/mpk/index Classes ------- .. autoapisummary:: afe.backends.Backend afe.backends.BackendIR afe.backends.ExprCheckInfo afe.backends.BaseChecker Package Contents ---------------- .. py:class:: Backend The Backend class contains all SiMa supported backends that can be partitioned via AFE's graph partitioning pass. During graph partitioning AFE will assign each IR in the graph to at least one of the backend type in this Backend class. The partitioned IRs will then be sent to its corresponding backend and runtime later. Currently AFE support 4 different backends graph annotation: * MLA - SiMa.ai 1st Machine Learning Accerator * APU - x86 or ARM A65 * EV - Synopsys' DSP IP * CPU - compile on x86 for simulation purpose, used for unsupported operators * NONE - For operations outside of partitions like tuple and tuple_getitem In the TVM, strings 'llvm' and 'arm' have special meaning, while others do not. .. py:attribute:: MLA :value: 'mla' .. py:attribute:: APU :value: 'arm' .. py:attribute:: EV :value: 'ev' .. py:attribute:: CPU :value: 'llvm' .. py:attribute:: NONE :value: 'none' .. py:method:: get_backend_from_name(name: str) -> Optional[Backend] :classmethod: .. py:class:: BackendIR IR of a computation that has been lowered to an external backend representation. The computation has an input/output interface like a node. :param graph: The lowered IR. The format of this IR depends on the backend. For Backend.MLA, it is a ModelGraph. For Backend.APU, it is a CompiledTVMObjectFile. :param type: AwesomeNet type of the lowered IR :param backend: Backend that the lowered IR is for. :param tessellate_parameters: Tessellation parameters obtained while compiling the BackendIR for MLA backend. Currently unused. :param detessellate_parameters: Detessellation parameters obtained while compiling the BackendIR for MLA backend. Used for creating a check file from untessellated data while executing the compiled BackendIR using N2ACompiledBackendRunner. :param stage: Stage number of the graph. Every graph have a unique stage number that represents their order in AwesomeNet. .. py:attribute:: graph :type: Any .. py:attribute:: type :type: afe.ir.tensor_type.NodeType .. py:attribute:: backend :type: Backend .. py:attribute:: pack_parameters :type: Any | None :value: None .. py:attribute:: unpack_parameters :type: Any | None :value: None .. py:attribute:: stage :type: int :value: 1 .. py:method:: get_type() -> Optional[afe.ir.tensor_type.NodeType] Get the type that this code has when it is used as a model graph node. :return: The node's type .. py:method:: set_batch_size(batch_size: int) Modifies BackendIR's internal parameters to accommodate for a given batch size. :param batch_size: Integer value representing the batch size of the inputs to the AwesomeNet. .. py:class:: ExprCheckInfo Properties of one Relay IR expression that are relevant to backend assignment. An ExprCheckInfo is passed to a backend checker for deciding whether the expression can run on that backend. :param name: Name of the expression's operator. :param attrs: A list of Relay operator attributes. If the expression is a composite operator, the list has one item for each call in the composite operator's body. Otherwise, it has a single item, which is the expression's attribute. :param input_shapes: Shapes of the expression's input tensors. :param is_constant: List of boolean values providing information whether certain input is a constant. :param: idx: The expression's index in the graph's topological order. .. py:attribute:: name :type: str .. py:attribute:: attrs :type: List[CheckerAttr] .. py:attribute:: input_shapes :type: CheckerInputShapes .. py:attribute:: is_constant :type: List[bool] .. py:attribute:: idx :type: int .. py:class:: BaseChecker A way to decide whether a given expression can be executed on a selected backend. This class should be implemented by subclassing and overriding the class variables. It is not meant to be instantiated. :param _checkers_name: str. Name of the checker's factory class. :param _backend: The type of the Backend. :param _predicate: Predicate that decides whether an operator can execute on the backend. .. py:method:: get_backend() -> afe.backends.Backend :classmethod: Return the backend for which this checker class makes decisions. .. py:method:: check(args: ExprCheckInfo) -> Decision :classmethod: Examine properties of an expression to decide whether the expression can be assigned to this checker's associated backend.