|
IRON 1.0
|
Public Member Functions | |
| __init__ (self, Sequence[int] tensor_dims, int offset, Sequence[int] sizes, Sequence[int] strides) | |
| Sequence[int] | tensor_dims (self) |
| int | offset (self) |
| Sequence[int] | sizes (self) |
| Sequence[int] | strides (self) |
| Sequence[tuple[int, int]] | transformation_dims (self) |
| tuple[np.ndarray, np.ndarray] | accesses (self) |
| np.ndarray | access_order (self) |
| np.ndarray | access_count (self) |
| Generator[int, None, None] | access_generator (self) |
| bool | compare_access_orders (self, TensorAccessPattern other) |
| None | visualize (self, bool|None show_arrows=None, str|None title=None, str|None file_path=None, bool show_plot=True, bool plot_access_count=False) |
| str | __str__ (self) |
| __eq__ (self, other) | |
| __ne__ (self, other) | |
Protected Member Functions | |
| tuple[np.ndarray, np.ndarray] | _calculate_accesses (self, bool calc_order, bool calc_count) |
Protected Attributes | |
| _tensor_dims | |
| _offset | |
| _sizes | |
| _strides | |
Static Protected Attributes | |
| _DTYPE = np.int32 | |
Private Attributes | |
| __class__ | |
A TensorAccessPattern represents a data access pattern applied to a tensor of a specific dimension. This is a base class meant to generically represent such as transformation using sizes, strides, and an offset.
| taplib.tap.TensorAccessPattern.__init__ | ( | self, | |
| Sequence[int] | tensor_dims, | ||
| int | offset, | ||
| Sequence[int] | sizes, | ||
| Sequence[int] | strides | ||
| ) |
An object representing an access pattern applied to a tensor.
Args:
tensor_dims (Sequence[int]): Dimensions of the tensor
offset (int): Offset into the tensor to begin the transformation
sizes (Sequence[int]): Transformation sizes
strides (Sequence[int]): Transformation strides
| taplib.tap.TensorAccessPattern.__eq__ | ( | self, | |
| other | |||
| ) |
| taplib.tap.TensorAccessPattern.__ne__ | ( | self, | |
| other | |||
| ) |
| str taplib.tap.TensorAccessPattern.__str__ | ( | self | ) |
|
protected |
| np.ndarray taplib.tap.TensorAccessPattern.access_count | ( | self | ) |
The access_count ndarray contains the number of times each element is
accessed by the tensor access pattern.
Returns:
np.ndarray: access_count
| Generator[int, None, None] taplib.tap.TensorAccessPattern.access_generator | ( | self | ) |
This function returns an iterator that returns the access index
into the flattened tensor that this access pattern represents. This can
be used to calculate the access count or to enumerate accesses.
Yields:
int: The next access index
| np.ndarray taplib.tap.TensorAccessPattern.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.
Returns:
np.ndarray: access_order
| tuple[np.ndarray, np.ndarray] taplib.tap.TensorAccessPattern.accesses | ( | self | ) |
Returns the access_order and access_count arrays.
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
| bool taplib.tap.TensorAccessPattern.compare_access_orders | ( | self, | |
| TensorAccessPattern | other | ||
| ) |
This function creates an alternative way to compare access patterns.
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.
Args:
other (TensorAccessPattern): The TensorAccessPattern to compare to
Raises:
ValueError: other must be of type TensorAccessPattern
Returns:
bool: True if the TensorAccessPatterns are functionally equivalent; false otherwise.
| int taplib.tap.TensorAccessPattern.offset | ( | self | ) |
Returns the offset into the tensor
Returns:
int: offset
| Sequence[int] taplib.tap.TensorAccessPattern.sizes | ( | self | ) |
A copy of the access pattern sizes
Returns:
Sequence[int]: Transformation sizes
| Sequence[int] taplib.tap.TensorAccessPattern.strides | ( | self | ) |
A copy of the access pattern strides
Returns:
Sequence[int]: Trsnformation strides
| Sequence[int] taplib.tap.TensorAccessPattern.tensor_dims | ( | self | ) |
A copy of the dimensions of the tensor
Returns:
Sequence[int]: Tensor dimensions
| Sequence[tuple[int, int]] taplib.tap.TensorAccessPattern.transformation_dims | ( | self | ) |
The access pattern represented as a sequence of (size, stride) tuples
Returns:
Sequence[tuple[int, int]]: Transformation dimensions
| None taplib.tap.TensorAccessPattern.visualize | ( | self, | |
| bool | None | show_arrows = None, |
||
| str | None | title = None, |
||
| str | None | file_path = None, |
||
| bool | show_plot = True, |
||
| bool | plot_access_count = False |
||
| ) |
Visualize the TensorAccessPattern using a graph.
Args:
show_arrows (bool | None, optional): Display arrows between sequentially accessed elements. Defaults to None.
title (str | None, optional): Title of the produced graph. Defaults to None.
file_path (str | None, optional): 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 for Jupyter notebooks). Defaults to True.
plot_access_count (bool, optional): Plot the access count in addition to the access order. Defaults to False.
Raises:
NotImplementedError: This function is not implemented for all dimensions.
|
private |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |