IRON
1.0
|
Public Member Functions | |
def | __init__ (self, Sequence[int] tensor_dims, int num_steps, int|None offset=None, Sequence[int]|None sizes=None, Sequence[int]|None strides=None, Callable[[int, int], int]|None offset_fn=None, Callable[[int, Sequence[int]], Sequence[int]]|None sizes_fn=None, Callable[[int, Sequence[int]], Sequence[int]]|None strides_fn=None) |
TensorAccessSequence | from_taps (cls, Sequence[TensorAccessPattern] taps) |
tuple[np.ndarray, np.ndarray] | accesses (self) |
np.ndarray | access_order (self) |
np.ndarray | access_count (self) |
animation.FuncAnimation | animate (self, str|None title=None, bool animate_access_count=False) |
None | visualize (self, str|None title=None, str|None file_path=None, bool show_plot=True, bool plot_access_count=False) |
bool | compare_access_orders (self, TensorAccessSequence other) |
def | __contains__ (self, TensorAccessPattern tap) |
def | __iter__ (self) |
int | __len__ (self) |
TensorAccessPattern | __getitem__ (self, int idx) |
def | __setitem__ (self, int idx, TensorAccessPattern tap) |
def | __delitem__ (self, int idx) |
def | insert (self, int index, TensorAccessPattern value) |
def | __eq__ (self, other) |
def | __ne__ (self, other) |
Private Member Functions | |
tuple[np.ndarray, np.ndarray] | _calc_accesses (self, bool calc_order, bool calc_count) |
Private Attributes | |
_current_step | |
_tensor_dims | |
_taps | |
TensorAccessSequence is a MutableSequence and an Iterable. Generally, it is a thin wrapper around a list[TensorAccessPattern]. The TensorAccessSequence is useful as a container of TensorAccessPatterns so that a grouping of patterns may be accessed in a particular order, or visualized or animated in sequence.
def taplib.tas.TensorAccessSequence.__init__ | ( | self, | |
Sequence[int] | tensor_dims, | ||
int | num_steps, | ||
int | None | offset = None , |
||
Sequence[int] | None | sizes = None , |
||
Sequence[int] | None | strides = None , |
||
Callable[[int, int], int] | None | offset_fn = None , |
||
Callable[[int, Sequence[int]], Sequence[int]] | None | sizes_fn = None , |
||
Callable[[int, Sequence[int]], Sequence[int]] | None | strides_fn = None |
||
) |
A TensorAccessSequence is a sequence of TensorAccessPatterns modelled after a list. The constructor can used given functions to generate a sequence of n steps. Allowed functions are the: * offset_fn(step: int, current_offset: int) -> new_offset: int * sizes_fn(step: int, current_sizes: Sequence[int]) -> new_sizes: Sequence[int] * strides_fn(step: int, currrent_strides: Sequence[int]) -> new_strides: Sequence[int] In lieu or in addition to a function, a default value for sizes/strides/offsets may also be set. Args: tensor_dims (Sequence[int]): Dimensions of the tensor. All TensorAccessPatterns in the sequence must share the tensor dimension. num_steps (int): Number of steps (elements) in the sequence. offset (int | None, optional): Offset into the sequence. Defaults to None. sizes (Sequence[int] | None, optional): Sizes for the TensorAccessPatterns Defaults to None. strides (Sequence[int] | None, optional): Strides for the TensorAccessPatterns in the sequence. Defaults to None. offset_fn (Callable[[int, int], int] | None, optional): A function to calculate the offset at each step. Defaults to None. sizes_fn (Callable[[int, Sequence[int]], Sequence[int]] | None, optional): A function to calculate the sizes at each step. Defaults to None. strides_fn (Callable[[int, Sequence[int]], Sequence[int]] | None, optional): A function to calculate the strides at teach step. Defaults to None. Raises: ValueError: Parameters are validated
def taplib.tas.TensorAccessSequence.__contains__ | ( | self, | |
TensorAccessPattern | tap | ||
) |
def taplib.tas.TensorAccessSequence.__delitem__ | ( | self, | |
int | idx | ||
) |
def taplib.tas.TensorAccessSequence.__eq__ | ( | self, | |
other | |||
) |
TensorAccessPattern taplib.tas.TensorAccessSequence.__getitem__ | ( | self, | |
int | idx | ||
) |
def taplib.tas.TensorAccessSequence.__iter__ | ( | self | ) |
int taplib.tas.TensorAccessSequence.__len__ | ( | self | ) |
def taplib.tas.TensorAccessSequence.__ne__ | ( | self, | |
other | |||
) |
def taplib.tas.TensorAccessSequence.__setitem__ | ( | self, | |
int | idx, | ||
TensorAccessPattern | tap | ||
) |
|
private |
np.ndarray taplib.tas.TensorAccessSequence.access_count | ( | self | ) |
The access_count ndarray contains the number of times each element is accessed by the tensor access pattern. The TensorAccessPatterns in the sequence are applied sequentially. Returns: np.ndarray: access_count
np.ndarray taplib.tas.TensorAccessSequence.access_order | ( | self | ) |
The access_order ndarray sequentially counts access to elements in the tensor. If an element is accessed more than once, only the last count is reflected. The TensorAccessPatterns in the sequence are applied sequentially. Returns: np.ndarray: access_order
tuple[np.ndarray, np.ndarray] taplib.tas.TensorAccessSequence.accesses | ( | self | ) |
Returns the access_order and access_count arrays of the TensorAccessPatterns in the sequence applied sequentially to the tensor. The access_order ndarray sequentially counts access to elements in the tensor. If an element is accessed more than once, only the last count is reflected. The access_count ndarray contains the number of times each element is accessed by the tensor access pattern. Returns: tuple[np.ndarray, np.ndarray]: access_order, access_count
animation.FuncAnimation taplib.tas.TensorAccessSequence.animate | ( | self, | |
str | None | title = None , |
||
bool | animate_access_count = False |
||
) |
Creates and returns a handle to a TensorAccessSequence animation. Each frame in the animation represents one TensorAccessPattern in the sequence. Args: title (str | None, optional): The title of the animation. Defaults to None. animate_access_count (bool, optional): Create an animation for the tensor access count, in addition to the tensor access order. Defaults to False. Raises: NotImplementedError: Not all dimensions of tensor may be visualized by animation at this time. Returns: animation.FuncAnimation: A handle to the animation, produced by the matplotlib.animation module.
bool taplib.tas.TensorAccessSequence.compare_access_orders | ( | self, | |
TensorAccessSequence | other | ||
) |
This function creates an alternative way to compare access pattern sequences. Sometimes access patterns with different sizes/strides are functionally equivalent; to detect functional equivalency, this function uses iterators produced by access_generator() to compare the access patterns. This is more performant than comparing the numpy array access_order or access_count tensors, particularly when comparing sequences containing multiple tensor access patterns. Args: other (TensorAccessSequence): The TensorAccessSequence to compare to Returns: bool: True is functionally equivalent; False otherwise.
TensorAccessSequence taplib.tas.TensorAccessSequence.from_taps | ( | cls, | |
Sequence[TensorAccessPattern] | taps | ||
) |
This alternative constructor creates a TensorAccessSequence from a sequence of TensorAccessPatterns. This is an alternative to the traditional constructor, and is useful for patterns that are difficult to express using the sizes/strides/offset functions. Args: taps (Sequence[TensorAccessPattern]): The sequence of tensor access patterns Raises: ValueError: At least one TensorAccessPattern must be specified ValueError: All TensorAccessPatterns in a sequence must share tensor dimensions Returns: TensorAccessSequence: A newly constructor TensorAccessSequence object
def taplib.tas.TensorAccessSequence.insert | ( | self, | |
int | index, | ||
TensorAccessPattern | value | ||
) |
None taplib.tas.TensorAccessSequence.visualize | ( | self, | |
str | None | title = None , |
||
str | None | file_path = None , |
||
bool | show_plot = True , |
||
bool | plot_access_count = False |
||
) |
Provides a visual of the TensorAccessSequence using a graph. Args: title (str | None, optional): The title of the graph. Defaults to None. file_path (str | None, optional): The path to save the graph at. If None, it is not saved. Defaults to None. show_plot (bool, optional): Show the plot; this is useful when running in a Jupyter notebook. Defaults to True. plot_access_count (bool, optional): Plot the access count in addition to the access order. Defaults to False. Raises: NotImplementedError: Not all dimensions of tensor may be visualized.
|
private |
|
private |
|
private |