/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/ops/common/utils.hpp Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/ops/common/utils.hpp Source File#

Composable Kernel: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/ck_tile/ops/common/utils.hpp Source File
utils.hpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: MIT
2 // Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved.
3 
4 #pragma once
5 
6 #include <iostream>
7 #include <string>
8 
9 #include "ck_tile/core.hpp"
10 
11 namespace ck_tile {
12 
13 // clang-format off
14 template <typename T> struct typeToStr;
15 template <> struct typeToStr<float> { static constexpr const char * name = "fp32"; };
16 template <> struct typeToStr<fp16_t> { static constexpr const char * name = "fp16"; };
17 template <> struct typeToStr<bf16_t> { static constexpr const char * name = "bf16"; };
18 template <> struct typeToStr<fp8_t> { static constexpr const char * name = "fp8"; };
19 template <> struct typeToStr<bf8_t> { static constexpr const char * name = "bf8"; };
20 template <> struct typeToStr<int8_t> { static constexpr const char * name = "int8"; };
21 template <> struct typeToStr<pk_int4_t> { static constexpr const char * name = "pk_int4"; };
22 
23 template <memory_operation_enum MemOp> struct memOpToStr;
24 template <> struct memOpToStr<memory_operation_enum::set> { static constexpr const char * name = "set"; };
25 template <> struct memOpToStr<memory_operation_enum::atomic_add> { static constexpr const char * name = "atomic_add"; };
26 template <> struct memOpToStr<memory_operation_enum::atomic_max> { static constexpr const char * name = "atomic_max"; };
27 template <> struct memOpToStr<memory_operation_enum::add> { static constexpr const char * name = "add"; };
28 // clang-format on
29 
30 template <typename ADataType_, typename BDataType_>
31 std::string gemm_prec_str()
32 {
33  std::string base_str = std::string(typeToStr<ADataType_>::name);
34  if(!std::is_same_v<ADataType_, BDataType_>)
35  {
36  base_str += "_" + std::string(typeToStr<BDataType_>::name);
37  }
38  return base_str;
39 }
40 
41 template <memory_operation_enum MemOp_>
42 std::string mem_op_string()
43 {
44  return std::string(memOpToStr<MemOp_>::name);
45 }
46 
47 } // namespace ck_tile
Definition: cluster_descriptor.hpp:13
_BitInt(8) fp8_t
Definition: float8.hpp:204
CK_TILE_DEVICE void atomic_add(X *p_dst, const X &x)
_Float16 fp16_t
Definition: half.hpp:110
int8_t int8_t
Definition: int8.hpp:20
CK_TILE_HOST_DEVICE T add(const T &a, const T &b)
Definition: generic_memory_space_atomic.hpp:16
bfloat16_t bf16_t
Definition: bfloat16.hpp:113
std::string mem_op_string()
Definition: utils.hpp:42
std::string gemm_prec_str()
Definition: utils.hpp:31
unsigned _BitInt(8) bf8_t
Definition: float8.hpp:206
__device__ X atomic_max(X *p_dst, const X &x)
Definition: utils.hpp:23
Definition: pk_int4.hpp:21
Definition: utils.hpp:14