tilelang.carver.template.base¶

Classes¶

BaseTemplate

Base class template for hardware-aware configurations.

Module Contents¶

class tilelang.carver.template.base.BaseTemplate¶

Bases: abc.ABC

Base class template for hardware-aware configurations. This serves as an abstract base class (ABC) that defines the structure for subclasses implementing hardware-specific optimizations.

abstract get_hardware_aware_configs(arch=None, topk=10)¶

Abstract method that must be implemented by subclasses. It should return a list of hardware-aware configurations (hints) based on the specified architecture.

Parameters:
  • arch (TileDevice, optional) – The target architecture. Defaults to None.

  • topk (int, optional) – Number of top configurations to return. Defaults to 10.

Returns:

A list of recommended hardware-aware configurations.

Return type:

List[Hint]

with_arch(arch)¶

Sets the architecture for this template and returns itself.

Parameters:

arch (TileDevice) – The architecture to set.

Returns:

The instance with the updated architecture.

Return type:

BaseTemplate

has_arch()¶

Checks whether the architecture is set.

Returns:

True if the architecture is set, False otherwise.

Return type:

bool

is_volta_arch()¶

Checks if the current architecture is a Volta architecture.

Returns:

True if the architecture is Volta, False otherwise.

Return type:

bool

is_ampere_arch()¶

Checks if the current architecture is an Ampere architecture.

Returns:

True if the architecture is Ampere, False otherwise.

Return type:

bool

is_cdna_arch()¶

Checks if the current architecture is a CDNA architecture.

Returns:

True if the architecture is CDNA, False otherwise.

Return type:

bool

equivalent_function()¶

Returns the function associated with this template.

Returns:

The stored function.

Return type:

PrimFunc

abstract initialize_function()¶

Placeholder method that should be implemented by subclasses. This method is responsible for initializing the function.

Raises:

NotImplementedError – If not implemented in the subclass.

Return type:

None

set_function(func)¶

Sets the function for this template and returns itself.

Parameters:

func (PrimFunc) – The function to associate with this template.

Returns:

The instance with the updated function.

Return type:

BaseTemplate

set_output_nodes(output_nodes)¶

Sets the output nodes for this template and returns itself.

Parameters:

output_nodes (List[OutputNode]) – The output nodes to associate with this template.

Returns:

The instance with the updated output nodes.

Return type:

BaseTemplate

recommend_hints(topk=10)¶

Provides a list of recommended hardware-aware configurations.

Parameters:

topk (int, optional) – Number of top configurations to return. Defaults to 10.

Returns:

A list of recommended configurations.

Return type:

List[Hint]

property arch: tilelang.carver.arch.TileDevice¶

Returns the current architecture.

Returns:

The architecture of this template.

Return type:

TileDevice

property output_nodes: List[tilelang.carver.roller.node.OutputNode]¶

Returns the output nodes associated with this template.

Returns:

The output nodes.

Return type:

List[OutputNode]

__post_init__()¶

Post-initialization method that is called after the data class is created. Ensures that the function is initialized.