qonnx.transformation.channels_last (module)
- class qonnx.transformation.channels_last.AbsorbChanFirstIntoMatMul
Bases:
qonnx.transformation.base.TransformationRemoves a transpose to channels first node if it is in front of a Flatten and MatMul (or Gemm) node.
The channels first transpose is fused into the initializer of the Quant node acting as a weight tensor for the MatMul/Gemm node. Reshape nodes with shape [1, -1] are also supported instead of Flatten nodes. Independent of whether the flattening operation was performed by a Flatten node or a Resphape node, a Flatten node will be reinserted in-front of the MatMul node.
- Note: This transformation removes some of the tensor shapes on the down-stream path.
Thus running shape inference afterwards is advised.
- apply(model)
- class qonnx.transformation.channels_last.ConvertToChannelsLastAndClean(make_input_channels_last=False)
Bases:
qonnx.transformation.base.TransformationConverts data layout dependent nodes to ChannelsLast nodes and inserts transformations. Then it tries to eliminate as many transformations as possible and moves the still existing ones as far upstream as possible.
- Parameters
make_input_channels_last (bool) – Also makes the input of the network channels last, otherwise a transpose node will be left at the beginning of the network. Defaults to False
- apply(model)
- class qonnx.transformation.channels_last.InsertChannelsLastDomainsAndTrafos
Bases:
qonnx.transformation.base.TransformationInserts ChannelsLast domain, where required and also inserts required transposes.
- apply(model)
- class qonnx.transformation.channels_last.MoveChanFirstDownstream
Bases:
qonnx.transformation.base.TransformationMoves channel first transformations further downstream.
- apply(model)
- class qonnx.transformation.channels_last.MoveChanLastUpstream
Bases:
qonnx.transformation.base.TransformationMoves channel last transformations further upstream.
- apply(model)
- class qonnx.transformation.channels_last.RemoveConsecutiveChanFirstAndChanLastTrafos
Bases:
qonnx.transformation.base.TransformationRemove two consecutive transformations, which would do: (ChannelsLast -> ChannelsFirst) -> (ChannelsFirst -> ChannelsLast) Or more concrete, the first converts to channels first and the second to channels last.
- apply(model)