Deeploy.Targets.Generic.Layers.MatMulLayer
- class Deeploy.Targets.Generic.Layers.MatMulLayer(maps: List[NodeMapper])
Bases:
ONNXLayer
Methods
- __init__(maps: List[NodeMapper])
__init__
(maps)bind
(ctxt)Attempt to bind the mapper; discard mapper if binding does not work
broadcast
(ctxt[, default_channels_first])Broadcasts the operator's shapes and updates the NetworkContext
codeTransform
(ctxt[, verbose])Apply CodeTransformations to associated mapper's binder
Returns the number of operations (1 MAC = 2 Ops) of this operator
computeShapes
(inputShapes, outputShapes, ...)Takes input and output shapes from the graph-representation and broadcasts them to a predefined layout
Discard the current Mapper
generate
(ctxt)Invoke mapper's generate method
parse
(ctxt, default_channels_first)Iterate through all possible mappers and elect the first one that work
Reset all discarded mappers
typeCheck
(ctxt)Invokes the mapper's typeCheck method
Attributes
All potential mappings of an ONNX Layer
The currently elected NodeMapper to represent this layer
Set of all NodeMappers which cannot be used to represent this layer
The represented operator
- computeOps()
Returns the number of operations (1 MAC = 2 Ops) of this operator
- bind(ctxt: NetworkContext) Tuple[NetworkContext, bool]
Attempt to bind the mapper; discard mapper if binding does not work
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
- Returns:
Updated NetworkContext and boolean to indicate success or failure
- Return type:
Tuple[NetworkContext, bool]
- broadcast(ctxt: NetworkContext, default_channels_first: bool = True) NetworkContext
Broadcasts the operator’s shapes and updates the NetworkContext
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
default_channels_first (bool) – Whether the default layout if channels-first or not
- Returns:
Updated NetworkContext
- Return type:
- Raises:
KeyError – Raises a KeyError if any tensor required is not found in the NetworkContext
RuntimeError – Raises a RuntimeError if any tensor’s shape could not be broadcast to the target shape
- codeTransform(ctxt: NetworkContext, verbose: CodeGenVerbosity = CodeGenVerbosity(tilingProfiling=None)) NetworkContext
Apply CodeTransformations to associated mapper’s binder
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
verbose (CodeGenVerbosity) – CodeGenVerbosity object to control verbosity of generated code
- Returns:
Updated NetworkContext
- Return type:
Tuple[NetworkContext, bool]
- computeShapes(inputShapes: Shape, outputShapes: Shape, operatorRepresentation: Dict[str, str | Any], channels_first: bool) Tuple[Shape, Shape]
Takes input and output shapes from the graph-representation and broadcasts them to a predefined layout
- Parameters:
inputShapes (Shape) – Graph-level input shape
outputShapes (Shape) – Graph-level output shapes
operatorRepresentation (OperatorRepresentation) – The node’s operatorRepresentation
channels_first (bool) – Whether this operator’s data layout is in CxHxW (true) or HxWxC (false) layout
- Returns:
Returns broadcasted shapes
- Return type:
Tuple[Shape, Shape]
- discardCurrentMapper()
Discard the current Mapper
- generate(ctxt: NetworkContext) Tuple[NetworkContext, List[str]]
Invoke mapper’s generate method
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
- Returns:
Updated NetworkContext and flag to indicate success
- Return type:
Tuple[NetworkContext, List[str]]
- parse(ctxt: NetworkContext, default_channels_first: bool) Tuple[NetworkContext, bool]
Iterate through all possible mappers and elect the first one that work
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
default_channels_first (bool) – Whether the default layout if channels-first or not
- Returns:
Updated NetworkContext and boolean to indicate success or failure
- Return type:
Tuple[NetworkContext, bool]
- resetDiscardedMappers()
Reset all discarded mappers
- typeCheck(ctxt: NetworkContext) Tuple[NetworkContext, bool]
Invokes the mapper’s typeCheck method
- Parameters:
ctxt (NetworkContext) – Current NetworkContext
- Returns:
Updated NetworkContext and boolean to indicate success or failure
- Return type:
Tuple[NetworkContext, bool]
- mapper: NodeMapper
The currently elected NodeMapper to represent this layer
- Type:
- discardedMappers: Set[NodeMapper]
Set of all NodeMappers which cannot be used to represent this layer
- Type:
Set[NodeMapper]
- node: gs.Node
The represented operator
- Type:
gs.Node
- maps
All potential mappings of an ONNX Layer
- Type:
List[NodeMapper]