Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Utilities

## Checks

Utility functions for checking constraints on kernels and calculating kernel attributes

cutlass.utils.check.alignment_or_default(alignment_provided, default_alignment)

  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)

  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)

  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)

  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)

  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)

  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)
  Parameters:

    math_op (MathOperation) –

cutlass.utils.datatypes.bfloat16_library_type(inp)
  Return type:

    DataType

cutlass.utils.datatypes.bfloat16_type(inp)
  Return type:

    bfloat16

cutlass.utils.datatypes.binding_layout(layout)

cutlass.utils.datatypes.binding_library_type(inp)

cutlass.utils.datatypes.binding_opclass(opclass)
  Parameters:

    opclass (OpcodeClass) –

cutlass.utils.datatypes.binding_type(inp)

cutlass.utils.datatypes.construct_backend_td(td, kernel_schedule)
  Parameters:

    - td (TileDescription) –

    - kernel_schedule (KernelScheduleType) –

  Return type:

    TileDescription

cutlass.utils.datatypes.cupy_library_type(inp)
  Return type:

    DataType

cutlass.utils.datatypes.cupy_type(inp)

cutlass.utils.datatypes.get_datatype_and_layout(tensor)

cutlass.utils.datatypes.has_binding_type(inp)
  Parameters:

    inp (DataType) –

cutlass.utils.datatypes.library_layout(layout)

cutlass.utils.datatypes.library_to_binding(inp)
  Parameters:

    inp (DataType) –

cutlass.utils.datatypes.library_type(inp)

cutlass.utils.datatypes.numpy_library_type(inp)
  Return type:

    DataType

cutlass.utils.datatypes.numpy_type(inp)

cutlass.utils.datatypes.td_from_profiler_op(op)

  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)

  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)
  Return type:

    DataType

cutlass.utils.datatypes.torch_type(inp)