dmx.compressor.fx.transformer.dmx_aware_transformer.DMXAwareTransformer
- class dmx.compressor.fx.transformer.dmx_aware_transformer.DMXAwareTransformer(module: GraphModule, node_name_to_scope: dict, old_gms: List[GraphModule] = None, nodeInputs: dict = None)
Substitute as in dmx.model.aware(), replace torch.nn.modules and activations with dmx counterpart
- Parameters:
module (fx.GraphModule) – the module to transform
node_name_to_scope (dict) – A dictionary storing the mapping between node names and scopes
- module
the module to transform
- Type:
fx.GraphModule
- node_name_to_scope
A dictionary storing the mapping between node names and scopes
- Type:
dict
- old_gms List[
dmxmodules to reuse if module was already transformed
- Type:
fx.GraphModule
- __init__(module: GraphModule, node_name_to_scope: dict, old_gms: List[GraphModule] = None, nodeInputs: dict = None)
Note
Backwards-compatibility for this API is guaranteed.
Methods
__init__(module, node_name_to_scope[, ...])add_dmx_aware_functional_mapping(target, ...)add_submod(name, mod)this function will try to reuse modules in old_gm if possible
boxed_run(args_list)Run module via interpretation and return the result.
call_function(target, args, kwargs)Execute a
call_functionnode, replaces the function with its dmx counterpart and returns the result.call_method(target, args, kwargs)Execute a
call_methodnode and return the result.call_module(target, args, kwargs)Execute a
call_modulenode, replaces the module with its dmx counterpart and returns the result.create_unique_name_in_scope(cand_name)fetch_args_kwargs_from_env(n)Fetch the concrete values of
argsandkwargsof nodenfrom the current execution environment.fetch_attr(target)Fetch an attribute from the
Modulehierarchy ofself.module.get_attr(target, args, kwargs)Execute a
get_attrnode.map_nodes_to_values(args, n)Recursively descend through
argsand look up the concrete value for eachNodein the current execution environment.merge_graph(subgraph, scope, args, kwargs)This function is to merge subgraph to graph
output(target, args, kwargs)Execute an
outputnode.placeholder(target, args, kwargs)Execute a
placeholdernode.run(*args[, initial_env, enable_io_processing])Run module via interpretation and return the result.
run_node(n)Run a specific node
nand return the result.transform()Transform
self.moduleand return the transformedGraphModule.