tilelang.carver.template.base module#

class tilelang.carver.template.base.BaseTemplate#

Bases: 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.

property arch: TileDevice#

Returns the current architecture.

Returns:

The architecture of this template.

Return type:

TileDevice

equivalent_function() PrimFunc#

Returns the function associated with this template.

Returns:

The stored function.

Return type:

PrimFunc

abstract get_hardware_aware_configs(arch: Optional[TileDevice] = None, topk: int = 10) List[Hint]#

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]

has_arch() bool#

Checks whether the architecture is set.

Returns:

True if the architecture is set, False otherwise.

Return type:

bool

initialize_function() None#

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

Raises:

NotImplementedError – If not implemented in the subclass.

is_ampere_arch() bool#

Checks if the current architecture is an Ampere architecture.

Returns:

True if the architecture is Ampere, False otherwise.

Return type:

bool

is_cdna_arch() bool#

Checks if the current architecture is a CDNA architecture.

Returns:

True if the architecture is CDNA, False otherwise.

Return type:

bool

is_volta_arch() bool#

Checks if the current architecture is a Volta architecture.

Returns:

True if the architecture is Volta, False otherwise.

Return type:

bool

property output_nodes: List[OutputNode]#

Returns the output nodes associated with this template.

Returns:

The output nodes.

Return type:

List[OutputNode]

recommend_hints(topk: int = 10) List[Hint]#

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]

set_function(func: PrimFunc) BaseTemplate#

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: List[OutputNode]) BaseTemplate#

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

with_arch(arch: TileDevice) BaseTemplate#

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