afe.backends

Submodules

Classes

Backend

The Backend class contains all SiMa supported backends that can be partitioned via AFE's

BackendIR

IR of a computation that has been lowered to an external backend representation.

ExprCheckInfo

Properties of one Relay IR expression that are relevant to backend assignment.

BaseChecker

A way to decide whether a given expression can be executed on a selected backend.

Package Contents

class afe.backends.Backend[source]

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.

MLA = 'mla'
APU = 'arm'
EV = 'ev'
CPU = 'llvm'
NONE = 'none'
classmethod get_backend_from_name(name: str) Backend | None[source]
class afe.backends.BackendIR[source]

IR of a computation that has been lowered to an external backend representation. The computation has an input/output interface like a node.

Parameters:
  • 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.

  • type – AwesomeNet type of the lowered IR

  • backend – Backend that the lowered IR is for.

  • tessellate_parameters – Tessellation parameters obtained while compiling the BackendIR for MLA backend. Currently unused.

  • 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.

  • stage – Stage number of the graph. Every graph have a unique stage number that represents their order in AwesomeNet.

graph: Any
type: afe.ir.tensor_type.NodeType
backend: Backend
pack_parameters: Any | None = None
unpack_parameters: Any | None = None
stage: int = 1
get_type() afe.ir.tensor_type.NodeType | None[source]

Get the type that this code has when it is used as a model graph node.

Returns:

The node’s type

set_batch_size(batch_size: int)[source]

Modifies BackendIR’s internal parameters to accommodate for a given batch size.

Parameters:

batch_size – Integer value representing the batch size of the inputs to the AwesomeNet.

class afe.backends.ExprCheckInfo[source]

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.

Parameters:
  • name – Name of the expression’s operator.

  • 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.

  • input_shapes – Shapes of the expression’s input tensors.

  • 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.

name: str
attrs: List[CheckerAttr]
input_shapes: CheckerInputShapes
is_constant: List[bool]
idx: int
class afe.backends.BaseChecker[source]

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.

Parameters:
  • _checkers_name – str. Name of the checker’s factory class.

  • _backend – The type of the Backend.

  • _predicate – Predicate that decides whether an operator can execute on the backend.

classmethod get_backend() afe.backends.Backend[source]

Return the backend for which this checker class makes decisions.

classmethod check(args: ExprCheckInfo) Decision[source]

Examine properties of an expression to decide whether the expression can be assigned to this checker’s associated backend.