dmx.compressor.fx.transformer.input_output_transformer

Classes

InputOutputTransformer(module[, scopeDict, cfg])

A transformer that transforms the module by adding additional ops, which includes: - casting - approximator - sparsifier

class dmx.compressor.fx.transformer.input_output_transformer.InputOutputTransformer(module: GraphModule, scopeDict: dict = None, cfg=None)

Bases: Transformer

A transformer that transforms the module by adding additional ops, which includes: - casting - approximator - sparsifier

Parameters:
  • module (fx.GraphModule) – module to be added with additional ops.

  • scopeDict (Optional[dict]) – Dictionary that maps node name to scope. Defaults to None.

  • cfg (Optional[str]) – config file for setting the added ops formats. Defaults to None.

module

module to be added with additional ops.

Type:

fx.GraphModule

scopeDict

Dictionary that maps node name to scope.

Type:

Optional[str]

cfg

config file for setting the added ops formats.

Type:

Optional[str]

call_function(target: Target, args: Tuple[tuple[Argument, ...] | Sequence[Argument] | Mapping[str, Argument] | slice | range | Node | str | int | float | bool | complex | dtype | Tensor | device | memory_format | layout | OpOverload | SymInt | SymBool | SymFloat | None, ...], kwargs: Dict[str, Any]) Any

Execute a call_function node. Insert a cast node after the node.

Parameters:
  • target (Target) – The call target for this node. See Node for details on semantics

  • args (Tuple) – Tuple of positional args for this invocation

  • kwargs (Dict) – Dict of keyword arguments for this invocation

Returns

A Proxy containing the last node added (cast) and the tracer of the new graph

call_method(target: Target, args: Tuple[tuple[Argument, ...] | Sequence[Argument] | Mapping[str, Argument] | slice | range | Node | str | int | float | bool | complex | dtype | Tensor | device | memory_format | layout | OpOverload | SymInt | SymBool | SymFloat | None, ...], kwargs: Dict[str, Any]) Any

Execute a call_method node.

Parameters:
  • target (Target) – The call target for this node. See Node for details on semantics

  • args (Tuple) – Tuple of positional args for this invocation

  • kwargs (Dict) – Dict of keyword arguments for this invocation

Returns

A Proxy containing the call_method node and the tracer of the new graph

get_attr(target: Target, args: Tuple[tuple[Argument, ...] | Sequence[Argument] | Mapping[str, Argument] | slice | range | Node | str | int | float | bool | complex | dtype | Tensor | device | memory_format | layout | OpOverload | SymInt | SymBool | SymFloat | None, ...], kwargs: Dict[str, Any]) Proxy

Execute a get_attr node. Insert a weight_cast/bias_cast after the node. Insert additional weight_sparsifier node if the current node is a weight node and sparsifier format is specified in the cfg file.

Parameters:
  • target (Target) – The call target for this node. See Node for details on semantics

  • args (Tuple) – Tuple of positional args for this invocation

  • kwargs (Dict) – Dict of keyword arguments for this invocation

Returns

A Proxy containing the last node added (output) and the tracer of the new graph

output(target: Target, args: Tuple[tuple[Argument, ...] | Sequence[Argument] | Mapping[str, Argument] | slice | range | Node | str | int | float | bool | complex | dtype | Tensor | device | memory_format | layout | OpOverload | SymInt | SymBool | SymFloat | None, ...], kwargs: Dict[str, Any]) Any

Execute an output node. Insert an output_cast module before the node.

Parameters:
  • target (Target) – The call target for this node. See Node for details on semantics

  • args (Tuple) – Tuple of positional args for this invocation

  • kwargs (Dict) – Dict of keyword arguments for this invocation

Returns:

A Proxy containing the last node added (output) and the tracer of the new graph

placeholder(target: Target, args: Tuple[tuple[Argument, ...] | Sequence[Argument] | Mapping[str, Argument] | slice | range | Node | str | int | float | bool | complex | dtype | Tensor | device | memory_format | layout | OpOverload | SymInt | SymBool | SymFloat | None, ...], kwargs: Dict[str, Any]) Proxy

Execute a placeholder node. Adds input_cast module after the node.

Parameters:
  • target (Target) – The call target for this node. See Node for details on semantics

  • args (Tuple) – Tuple of positional args for this invocation

  • kwargs (Dict) – Dict of keyword arguments for this invocation

Returns:

A Proxy containing the last node added (input_cast) and the tracer of the new graph