Utilities#

Checks#

Utility functions for checking constraints on kernels and calculating kernel attributes

cutlass.utils.check.alignment_or_default(alignment_provided, default_alignment)[source]#

Returns alignment_provided if it is set, otherwise default_alignment and checks that alignment_provided does not exceed default_alignment.

Parameters:
  • alignment_provided (int) – alignment preference specified. Can be None.

  • default_alignment (int) – alignment to use if alignment_provided is None

Returns:

alignment to use

Return type:

int

cutlass.utils.check.calculate_smem_usage(operation)[source]#

Returns the amount of shared memory in bytes consumed by a kernel.

Returns:

number of bytes of shared memory consumed by the operation

Returns:

int

cutlass.utils.check.calculate_smem_usage_per_stage(tile_description, operation_kind)[source]#

Returns the amount of shared memory in bytes consumed in a single stage of a kernel.

Returns:

number of bytes of shared memory consumed by a single stage

Return type:

int

cutlass.utils.check.valid_cluster_shape(cc, cluster_shape)[source]#

Checks whether a device with cc supports a thread block cluster of shape cluster_shape.

Parameters:
  • cc (int) – compute capability of device in question

  • cluster_shape (list) – dimensions of thread block cluster shape to check

Returns:

tuple with the first element indicating whether the provided cluster shape is valid for the provided device and the second element being an error message

Return type:

tuple

cutlass.utils.check.valid_kernel_schedule(cc, kernel_schedule)[source]#

Checks whether a device with cc supports kernel_schedule.

Parameters:
  • cc (int) – compute capability of device in question

  • kernel_schedule (KernelScheduleType) – kernel schedule type

Returns:

tuple with the first element indicating whether the provided kernel schedule is valid for the provided device and the second element being an error message

Return type:

tuple

cutlass.utils.check.valid_stage_count(cc, td)[source]#

Checks whether a device with cc supports the number of stages within tile_description, both based on raw limits on the number of stages and based on shared memory capacity

Parameters:
  • cc (int) – compute capability of device in question

  • td (TileDescription) – tile description to check

Returns:

tuple with the first element indicating whether the provided tile description is valid for the provided device and the second element being an error message

Return type:

tuple

Data Types#

Utility functions for converting between frontend datatypes and CUTLASS datatypes

cutlass.utils.datatypes.backend_math_operation(math_op)[source]#
Parameters:

math_op (MathOperation) –

cutlass.utils.datatypes.bfloat16_library_type(inp)[source]#
Return type:

DataType

cutlass.utils.datatypes.bfloat16_type(inp)[source]#
Return type:

bfloat16

cutlass.utils.datatypes.binding_layout(layout)[source]#
cutlass.utils.datatypes.binding_library_type(inp)[source]#
cutlass.utils.datatypes.binding_opclass(opclass)[source]#
Parameters:

opclass (OpcodeClass) –

cutlass.utils.datatypes.binding_type(inp)[source]#
cutlass.utils.datatypes.construct_backend_td(td, kernel_schedule)[source]#
Parameters:
  • td (TileDescription) –

  • kernel_schedule (KernelScheduleType) –

Return type:

TileDescription

cutlass.utils.datatypes.cupy_library_type(inp)[source]#
Return type:

DataType

cutlass.utils.datatypes.cupy_type(inp)[source]#
cutlass.utils.datatypes.get_datatype_and_layout(tensor)[source]#
cutlass.utils.datatypes.has_binding_type(inp)[source]#
Parameters:

inp (DataType) –

cutlass.utils.datatypes.library_layout(layout)[source]#
cutlass.utils.datatypes.library_to_binding(inp)[source]#
Parameters:

inp (DataType) –

cutlass.utils.datatypes.library_type(inp)[source]#
cutlass.utils.datatypes.numpy_library_type(inp)[source]#
Return type:

DataType

cutlass.utils.datatypes.numpy_type(inp)[source]#
cutlass.utils.datatypes.td_from_profiler_op(op)[source]#

Converts the profiler’s TileDescription in op into the backend TileDescription

Parameters:

op – profiler Operation

Returns:

backend TileDescription

Return type:

cutlass.backend.TileDescription

cutlass.utils.datatypes.td_from_profiler_td(td)[source]#

Converts the profiler’s TileDescription into the backend TileDescription

Parameters:

td (cutlass.TileDescription) – profiler TileDescription

Returns:

backend TileDescription

Return type:

cutlass.backend.TileDescription

cutlass.utils.datatypes.torch_library_type(inp)[source]#
Return type:

DataType

cutlass.utils.datatypes.torch_type(inp)[source]#