IRON  1.0
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
taplib.tap.TensorAccessPattern Class Reference

Public Member Functions

def __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)
 
def __eq__ (self, other)
 
def __ne__ (self, other)
 

Private Member Functions

tuple[np.ndarray, np.ndarray] _calculate_accesses (self, bool calc_order, bool calc_count)
 

Private Attributes

 _tensor_dims
 
 _offset
 
 _strides
 
 _sizes
 

Static Private Attributes

 _DTYPE = np.int32
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ __init__()

def 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

Member Function Documentation

◆ __eq__()

def taplib.tap.TensorAccessPattern.__eq__ (   self,
  other 
)

◆ __ne__()

def taplib.tap.TensorAccessPattern.__ne__ (   self,
  other 
)

◆ __str__()

str taplib.tap.TensorAccessPattern.__str__ (   self)

◆ _calculate_accesses()

tuple[np.ndarray, np.ndarray] taplib.tap.TensorAccessPattern._calculate_accesses (   self,
bool  calc_order,
bool   calc_count 
)
private

◆ access_count()

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

◆ access_generator()

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

◆ access_order()

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

◆ accesses()

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

◆ compare_access_orders()

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.

◆ offset()

int taplib.tap.TensorAccessPattern.offset (   self)
Returns the offset into the tensor

Returns:
    int: offset

◆ sizes()

Sequence[int] taplib.tap.TensorAccessPattern.sizes (   self)
A copy of the access pattern sizes

Returns:
    Sequence[int]: Transformation sizes

◆ strides()

Sequence[int] taplib.tap.TensorAccessPattern.strides (   self)
A copy of the access pattern strides

Returns:
    Sequence[int]: Trsnformation strides

◆ tensor_dims()

Sequence[int] taplib.tap.TensorAccessPattern.tensor_dims (   self)
A copy of the dimensions of the tensor

Returns:
    Sequence[int]: Tensor dimensions

◆ transformation_dims()

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

◆ visualize()

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.

Member Data Documentation

◆ _DTYPE

taplib.tap.TensorAccessPattern._DTYPE = np.int32
staticprivate

◆ _offset

taplib.tap.TensorAccessPattern._offset
private

◆ _sizes

taplib.tap.TensorAccessPattern._sizes
private

◆ _strides

taplib.tap.TensorAccessPattern._strides
private

◆ _tensor_dims

taplib.tap.TensorAccessPattern._tensor_dims
private

The documentation for this class was generated from the following file: