chop.passes.transform.pruning#
prune_transform_pass#
- chop.passes.graph.transforms.pruning.prune.prune_transform_pass(graph, pass_args: dict = {})[source]#
Apply pruning transformation to the given graph. This is achieved by adding a register_parametrization hook to weights and a register_pre_forward hook to activations
- Parameters:
graph (MaseGraph) – The input graph to be pruned.
pass_args (dict) – Optional arguments for the pruning transformation.
pass_args should take the following form:
pass_config = { "weight" : { "scope": "local", # ["local, "global"] are available "granularity": "element", # ["element"] are available "method": "l1", # ["l1", "random"] are available "sparsity": 0.5, # a float between 0.0 and 1.0 }, "activation" : { "scope": "local", # ["local, "global"] are available "granularity": "element", # ["element"] are available "method": "l1", # ["l1", "random"] are available "sparsity": 0.5, # a float between 0.0 and 1.0 }
- Returns:
The pruned graph and an empty dictionary.
- Return type:
tuple
prune_detach_hook_transform_pass#
- chop.passes.graph.transforms.pruning.prune_detach_hook.prune_detach_hook_transform_pass(graph, pass_args: dict = {})[source]#
Apply pruning transformation to the given graph. This is achieved by adding a register_parametrization hook to weights and a register_pre_forward hook to activations
- Parameters:
graph (MaseGraph) – The input graph to be pruned.
pass_args can be None or an empty dictionary.
- Parameters:
pass_args (dict) – Optional arguments for the pruning transformation.
- Returns:
The pruned graph and an empty dictionary.
- Return type:
tuple