ocl.utils.trees
Utilities for working with our own version of PyTrees which focus on torch tensors.
PyTrees are any nested structure of dictionaries, lists, tuples, namedtuples or dataclasses.
is_tensor_or_module
is_namedtuple
get_tree_element
Get element of a tree.
Source code in ocl/utils/trees.py
walk_tree_with_paths
Walk over all tensors + modules and their paths in a nested structure.
This could lead to an infinite loop.
Source code in ocl/utils/trees.py
reduce_tree
Apply reduction function to a list of nested dicts.
This only considers tensors at the moment, for other data types are simply copied from the first element.
Source code in ocl/utils/trees.py
map_tree
Apply a function to each element of a tree.
This only considers tensors at the moment, for other data types are simply copied from the first element.