mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-02 20:51:23 +00:00
Codegen hipRTC compilation (#1579)
* updating codegen build for MIOpen access: adding .cmake for codegen component * updating CMake * adding in header guards for some headers due to issues with hiprtc compilation in MIOpen * some more header guards * putting env file in header guard * cleaning up some includes * updated types file for hiprtc purposes * fixed types file: bit-wise/memcpy issue * updating multiple utility files to deal with standard header inclusion for hiprtc * added some more header guards in the utility files, replacing some standard header functionality * added some more header guards * fixing some conflicts in utility files, another round of header guards * fixing errors in data type file * resolved conflict errors in a few utility files * added header guards/replicated functionality in device files * resolved issues with standard headers in device files: device_base and device_grouped_conv_fwd_multiple_abd * resolved issues with standard headers in device files: device_base.hpp, device_grouped_conv_fwd_multiple_abd.hpp, device_grouped_conv_fwd_multiple_abd_xdl_cshuffle.hpp * added header guards for gridwise gemm files: gridwise_gemm_multiple_abd_xdl_cshuffle.hpp and gridwise_gemm_multiple_d_xdl_cshuffle.hpp * fixed issue with numerics header, removed from transform_conv_fwd_to_gemm and added to device_column_to_image_impl, device_grouped_conv_fwd_multiple_abd_xdl_cshuffle, device_grouped_conv_fwd_multiple_abd_xdl_cshuffle_v3, device_image_to_column_impl * replaced standard header usage and added header guards in block to ctile map and gridwise_gemm_pipeline_selector * resolved errors in device_gemm_xdl_splitk_c_shuffle files in regards to replacement of standard headers in previous commit * added replicated functionality for standard header methods in utility files * replaced standard header functionality in threadwise tensor slice transfer files and added header guards in element_wise_operation.hpp * temp fix for namespace error in MIOpen * remove standard header usage in codegen device op * removed standard header usage in elementwise files, resolved namespace errors * formatting fix * changed codegen argument to ON for testing * temporarily removing codegen compiler flag for testing purposes * added codegen flag again, set default to ON * set codegen flag default back to OFF * replaced enable_if_t standard header usage in data_type.hpp * added some debug prints to pinpoint issues in MIOpen * added print outs to debug in MIOpen * removed debug print outs from device op * resolved stdexcept include error * formatting fix * adding includes to new fp8 file to resolve ck::enable_if_t errors * made changes to amd_wave_read_first_lane * updated functionality in type utility file * fixed end of file issue * resovled errors in type utility file, added functionality to array utility file * fixed standard header usage replication in data_type file, resolves error with failing examples on navi3x * formatting fix * replaced standard header usage in amd_ck_fp8 file * added include to random_gen file * removed and replicated standard header usage from data_type and type_convert files for fp8 changes * replicated standard unsigned integer types in random_gen * resolved comments from review: put calls to reinterpret_cast for size_t in header guards * updated/added copyright headers * removed duplicate header * fixed typo in header guard * updated copyright headers --------- Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -131,7 +131,7 @@ struct ThreadGroupTensorSliceTransfer_v7r2
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
using is_tuple = decltype(std::declval<T&>().IsTuple());
|
||||
using is_tuple = decltype(ck::declval<T&>().IsTuple());
|
||||
|
||||
template <typename DstBuffers, index_t ThreadScratchId = 0>
|
||||
__device__ void RunWrite(const DstDescs& dst_descs,
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
namespace ck {
|
||||
namespace tensor_operation {
|
||||
@@ -18,6 +20,7 @@ enum struct ConvolutionForwardSpecialization
|
||||
Filter3x3,
|
||||
};
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
inline std::string getConvForwardSpecializationString(const ConvolutionForwardSpecialization& s)
|
||||
{
|
||||
switch(s)
|
||||
@@ -30,6 +33,7 @@ inline std::string getConvForwardSpecializationString(const ConvolutionForwardSp
|
||||
default: return "Unrecognized specialization!";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace device
|
||||
} // namespace tensor_operation
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <regex>
|
||||
#include <optional>
|
||||
|
||||
#include "ck/stream_config.hpp"
|
||||
#endif
|
||||
|
||||
namespace ck {
|
||||
namespace tensor_operation {
|
||||
namespace device {
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
#define GET_OBJECT_NAME_IMLP \
|
||||
std::optional<std::string> GetObjectName() const override \
|
||||
{ \
|
||||
@@ -41,7 +43,9 @@ namespace device {
|
||||
}
|
||||
|
||||
#define REGISTER_EXTRA_PRINTING_METHODS GET_OBJECT_NAME_IMLP GET_TEMPLATE_INFO_IMPL
|
||||
#endif
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
struct BaseArgument
|
||||
{
|
||||
BaseArgument() = default;
|
||||
@@ -66,13 +70,14 @@ struct BaseInvoker
|
||||
|
||||
virtual ~BaseInvoker() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
struct BaseOperator
|
||||
{
|
||||
BaseOperator() = default;
|
||||
BaseOperator(const BaseOperator&) = default;
|
||||
BaseOperator& operator=(const BaseOperator&) = default;
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
virtual bool IsSupportedArgument(const BaseArgument*) { return false; }
|
||||
virtual std::string GetTypeString() const { return ""; }
|
||||
|
||||
@@ -100,7 +105,7 @@ struct BaseOperator
|
||||
assert(p_arg);
|
||||
p_arg->p_workspace_ = p_workspace;
|
||||
}
|
||||
|
||||
#endif
|
||||
virtual ~BaseOperator() {}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2023-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2023-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
#include <array>
|
||||
#endif
|
||||
|
||||
#include "ck/tensor_operation/gpu/device/device_base.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/impl/device_grouped_conv_utils.hpp"
|
||||
@@ -13,8 +15,13 @@ namespace ck {
|
||||
namespace tensor_operation {
|
||||
namespace device {
|
||||
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
template <typename T>
|
||||
using is_tuple = decltype(ck::declval<T&>().IsTuple());
|
||||
#else
|
||||
template <typename T>
|
||||
using is_tuple = decltype(std::declval<T&>().IsTuple());
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Grouped Convolution Forward
|
||||
@@ -72,12 +79,18 @@ struct DeviceGroupedConvFwdMultipleABD : public BaseOperator
|
||||
static constexpr index_t NumDTensor = DsDataType::Size();
|
||||
|
||||
static_assert(NumDTensor == DsLayout::Size(), "wrong! Inconsistent NumDTensor");
|
||||
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
using APointers = ck::conditional_t<isMultiA, ck::Array<const void*, NumATensor>&, const void*>;
|
||||
using BPointers = ck::conditional_t<isMultiB, ck::Array<const void*, NumBTensor>&, const void*>;
|
||||
#else
|
||||
// If DataType is tuple, user has to pass std::array with pointers.
|
||||
using APointers =
|
||||
std::conditional_t<isMultiA, std::array<const void*, NumATensor>&, const void*>;
|
||||
ck::conditional_t<isMultiA, std::array<const void*, NumATensor>&, const void*>;
|
||||
using BPointers =
|
||||
std::conditional_t<isMultiB, std::array<const void*, NumBTensor>&, const void*>;
|
||||
ck::conditional_t<isMultiB, std::array<const void*, NumBTensor>&, const void*>;
|
||||
#endif
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
|
||||
/**
|
||||
* \brief Make argument pointer for grouped conv fwd.
|
||||
@@ -150,6 +163,7 @@ struct DeviceGroupedConvFwdMultipleABD : public BaseOperator
|
||||
const CDEElementwiseOperation& cde_element_op) = 0;
|
||||
|
||||
virtual std::unique_ptr<BaseInvoker> MakeInvokerPointer() = 0;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace device
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -29,6 +29,7 @@ enum struct GemmSpecialization
|
||||
MNKOPadding,
|
||||
};
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
inline std::string getGemmSpecializationString(const GemmSpecialization& s)
|
||||
{
|
||||
switch(s)
|
||||
@@ -52,6 +53,7 @@ inline std::string getGemmSpecializationString(const GemmSpecialization& s)
|
||||
default: return "Unrecognized specialization!";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace device
|
||||
} // namespace tensor_operation
|
||||
|
||||
@@ -3,11 +3,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "ck/host_utility/device_prop.hpp"
|
||||
#include "ck/host_utility/kernel_launch.hpp"
|
||||
#endif
|
||||
|
||||
#include "ck/utility/common_header.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor.hpp"
|
||||
@@ -15,15 +21,12 @@
|
||||
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/convolution_forward_specialization.hpp"
|
||||
#include "ck/tensor_operation/operator_transform/transform_conv_fwd_to_gemm.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/device_grouped_conv_fwd_multiple_abd.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/gemm_specialization.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/matrix_padder.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/device_grouped_conv_fwd_multiple_abd.hpp"
|
||||
#include "ck/tensor_operation/gpu/grid/gridwise_gemm_multiple_d_xdl_cshuffle.hpp"
|
||||
#include "ck/tensor_operation/gpu/grid/gridwise_gemm_multiple_abd_xdl_cshuffle.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/impl/device_grouped_conv_utils.hpp"
|
||||
#include "ck/host_utility/device_prop.hpp"
|
||||
#include "ck/host_utility/kernel_launch.hpp"
|
||||
#include "ck/host_utility/io.hpp"
|
||||
|
||||
namespace ck {
|
||||
namespace tensor_operation {
|
||||
@@ -259,8 +262,13 @@ __global__ void
|
||||
|
||||
} // namespace
|
||||
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
template <typename T>
|
||||
using is_tuple = decltype(ck::declval<T&>().IsTuple());
|
||||
#else
|
||||
template <typename T>
|
||||
using is_tuple = decltype(std::declval<T&>().IsTuple());
|
||||
#endif
|
||||
|
||||
//
|
||||
// @brief Device Convolution operation.
|
||||
@@ -429,8 +437,8 @@ struct CodegenDeviceGroupedConvFwdMultipleABD_Xdl_CShuffle
|
||||
|
||||
// If we are using multiAB and one of the template datatype parameters is not a tuple, convert
|
||||
// it to it
|
||||
using GemmADataType = std::conditional_t<!isMultiA && isMultiB, Tuple<ADataType>, ADataType>;
|
||||
using GemmBDataType = std::conditional_t<!isMultiB && isMultiA, Tuple<BDataType>, BDataType>;
|
||||
using GemmADataType = ck::conditional_t<!isMultiA && isMultiB, Tuple<ADataType>, ADataType>;
|
||||
using GemmBDataType = ck::conditional_t<!isMultiB && isMultiA, Tuple<BDataType>, BDataType>;
|
||||
|
||||
#define GridwiseGemmTemplateParameters \
|
||||
GemmADataType, GemmBDataType, ComputeDataType, AccDataType, CShuffleDataType, DsDataType, \
|
||||
@@ -449,15 +457,13 @@ struct CodegenDeviceGroupedConvFwdMultipleABD_Xdl_CShuffle
|
||||
CDEBlockTransferScalarPerVector_NPerBlock, LoopSched
|
||||
// Use appropriate gridwise gemm
|
||||
using GridwiseGemm =
|
||||
std::conditional_t<isMultiA || isMultiB,
|
||||
GridwiseGemmMultipleABD_xdl_cshuffle<GridwiseGemmTemplateParameters>,
|
||||
GridwiseGemmMultipleD_xdl_cshuffle<GridwiseGemmTemplateParameters>>;
|
||||
ck::conditional_t<isMultiA || isMultiB,
|
||||
GridwiseGemmMultipleABD_xdl_cshuffle<GridwiseGemmTemplateParameters>,
|
||||
GridwiseGemmMultipleD_xdl_cshuffle<GridwiseGemmTemplateParameters>>;
|
||||
|
||||
// If ADataTypes or BDataTypes is tuple, user has to pass ck::Array with pointers.
|
||||
using APointers =
|
||||
std::conditional_t<isMultiA, ck::Array<const void*, NumATensor>&, const void*>;
|
||||
using BPointers =
|
||||
std::conditional_t<isMultiB, ck::Array<const void*, NumBTensor>&, const void*>;
|
||||
using APointers = ck::conditional_t<isMultiA, ck::Array<const void*, NumATensor>&, const void*>;
|
||||
using BPointers = ck::conditional_t<isMultiB, ck::Array<const void*, NumBTensor>&, const void*>;
|
||||
// Use Tuple for the both cases for GridPointer to initialize it in Argument constructor (not
|
||||
// in initializer list what is required for single const pointer).
|
||||
using AGridPointer = remove_cvref_t<
|
||||
@@ -812,7 +818,6 @@ struct CodegenDeviceGroupedConvFwdMultipleABD_Xdl_CShuffle
|
||||
|
||||
static_for<0, NumDTensor, 1>{}([&](auto i) {
|
||||
using DLayout = remove_cvref_t<tuple_element_t<i.value, DsLayout>>;
|
||||
|
||||
// FIXME: layout
|
||||
if constexpr(is_same_v<DLayout, ctc::G_NW_K> || is_same_v<DLayout, ctc::G_NHW_K> ||
|
||||
is_same_v<DLayout, ctc::G_NDHW_K> || is_same_v<DLayout, ctc::GNWK> ||
|
||||
@@ -965,18 +970,18 @@ struct CodegenDeviceGroupedConvFwdMultipleABD_Xdl_CShuffle
|
||||
const BElementwiseOperation& b_element_op,
|
||||
const CDEElementwiseOperation& cde_element_op)
|
||||
{
|
||||
std::array<index_t, NDimSpatial + 3> a_g_n_c_wis_lengths_i32;
|
||||
std::array<index_t, NDimSpatial + 3> a_g_n_c_wis_strides_i32;
|
||||
std::array<index_t, NDimSpatial + 3> b_g_k_c_xs_lengths_i32;
|
||||
std::array<index_t, NDimSpatial + 3> b_g_k_c_xs_strides_i32;
|
||||
std::array<std::array<index_t, NDimSpatial + 3>, NumDTensor> ds_g_n_k_wos_lengths_i32;
|
||||
std::array<std::array<index_t, NDimSpatial + 3>, NumDTensor> ds_g_n_k_wos_strides_i32;
|
||||
std::array<index_t, NDimSpatial + 3> e_g_n_k_wos_lengths_i32;
|
||||
std::array<index_t, NDimSpatial + 3> e_g_n_k_wos_strides_i32;
|
||||
std::array<index_t, NDimSpatial> conv_filter_strides_i32;
|
||||
std::array<index_t, NDimSpatial> conv_filter_dilations_i32;
|
||||
std::array<index_t, NDimSpatial> input_left_pads_i32;
|
||||
std::array<index_t, NDimSpatial> input_right_pads_i32;
|
||||
ck::Array<index_t, NDimSpatial + 3> a_g_n_c_wis_lengths_i32;
|
||||
ck::Array<index_t, NDimSpatial + 3> a_g_n_c_wis_strides_i32;
|
||||
ck::Array<index_t, NDimSpatial + 3> b_g_k_c_xs_lengths_i32;
|
||||
ck::Array<index_t, NDimSpatial + 3> b_g_k_c_xs_strides_i32;
|
||||
ck::Array<ck::Array<index_t, NDimSpatial + 3>, NumDTensor> ds_g_n_k_wos_lengths_i32;
|
||||
ck::Array<ck::Array<index_t, NDimSpatial + 3>, NumDTensor> ds_g_n_k_wos_strides_i32;
|
||||
ck::Array<index_t, NDimSpatial + 3> e_g_n_k_wos_lengths_i32;
|
||||
ck::Array<index_t, NDimSpatial + 3> e_g_n_k_wos_strides_i32;
|
||||
ck::Array<index_t, NDimSpatial> conv_filter_strides_i32;
|
||||
ck::Array<index_t, NDimSpatial> conv_filter_dilations_i32;
|
||||
ck::Array<index_t, NDimSpatial> input_left_pads_i32;
|
||||
ck::Array<index_t, NDimSpatial> input_right_pads_i32;
|
||||
|
||||
array_convert(a_g_n_c_wis_lengths_i32, a_g_n_c_wis_lengths);
|
||||
array_convert(a_g_n_c_wis_strides_i32, a_g_n_c_wis_strides);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ck/library/utility/numeric.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor_helper.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/device_conv_tensor_rearrange.hpp"
|
||||
|
||||
@@ -205,8 +205,8 @@ struct DeviceGemmXdlSplitKCShuffle : public DeviceGemmSplitK<ALayout,
|
||||
|
||||
const auto b2c_map = DefaultBlock2CTileMap{};
|
||||
index_t gdx, gdy, gdz;
|
||||
std::tie(gdx, gdy, gdz) = b2c_map.CalculateGridSize(karg.M, karg.N, karg.k_batch);
|
||||
const auto K0Padded = karg.K0Padded;
|
||||
ck::tie(gdx, gdy, gdz) = b2c_map.CalculateGridSize(karg.M, karg.N, karg.k_batch);
|
||||
const auto K0Padded = karg.K0Padded;
|
||||
|
||||
const bool has_main_k0_block_loop = GridwiseGemm::CalculateHasMainK0BlockLoop(K0Padded);
|
||||
|
||||
|
||||
@@ -183,8 +183,8 @@ struct DeviceGemmXdlSplitKCShuffle_LdsDirectLoad : public DeviceGemmSplitK<ALayo
|
||||
|
||||
const auto b2c_map = DefaultBlock2CTileMap{};
|
||||
index_t gdx, gdy, gdz;
|
||||
std::tie(gdx, gdy, gdz) = b2c_map.CalculateGridSize(karg.M, karg.N, karg.k_batch);
|
||||
const auto K0Padded = karg.K0Padded;
|
||||
ck::tie(gdx, gdy, gdz) = b2c_map.CalculateGridSize(karg.M, karg.N, karg.k_batch);
|
||||
const auto K0Padded = karg.K0Padded;
|
||||
|
||||
const bool has_main_k0_block_loop = GridwiseGemm::CalculateHasMainK0BlockLoop(K0Padded);
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
|
||||
#include "ck/library/utility/numeric.hpp"
|
||||
#include "ck/utility/common_header.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor_helper.hpp"
|
||||
@@ -212,9 +213,13 @@ __global__ void
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
template <typename T>
|
||||
using is_tuple = decltype(ck::declval<T&>().IsTuple());
|
||||
#else
|
||||
template <typename T>
|
||||
using is_tuple = decltype(std::declval<T&>().IsTuple());
|
||||
#endif
|
||||
|
||||
//
|
||||
// @brief Device Convolution operation.
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <numeric>
|
||||
#include <sstream>
|
||||
|
||||
#include "ck/library/utility/numeric.hpp"
|
||||
#include "ck/utility/common_header.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor_helper.hpp"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ck/library/utility/numeric.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor.hpp"
|
||||
#include "ck/tensor_description/tensor_descriptor_helper.hpp"
|
||||
#include "ck/tensor_operation/gpu/device/device_conv_tensor_rearrange.hpp"
|
||||
|
||||
@@ -430,6 +430,7 @@ struct G_NDHW : public BaseTensorLayout
|
||||
|
||||
} // namespace convolution
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
template <
|
||||
typename Layout,
|
||||
typename std::enable_if<std::is_base_of<BaseTensorLayout, Layout>::value, bool>::type = false>
|
||||
@@ -438,6 +439,7 @@ std::ostream& operator<<(std::ostream& os, const Layout&)
|
||||
os << Layout::name;
|
||||
return os;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace tensor_layout
|
||||
} // namespace ck
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -340,8 +340,8 @@ struct Bilinear
|
||||
};
|
||||
|
||||
template <>
|
||||
__host__ __device__ constexpr void operator()<std::int8_t, std::int32_t, std::int8_t>(
|
||||
std::int8_t& y, const std::int32_t& x0, const std::int8_t& x1) const
|
||||
__host__ __device__ constexpr void
|
||||
operator()<int8_t, int32_t, int8_t>(int8_t& y, const int32_t& x0, const int8_t& x1) const
|
||||
{
|
||||
y = type_convert<int8_t>(alpha_ * type_convert<float>(x0) +
|
||||
beta_ * type_convert<float>(x1));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -533,7 +533,7 @@ struct NormalizeInInfer
|
||||
const T3& gamma,
|
||||
const T4& beta) const
|
||||
{
|
||||
static_assert(std::is_same<T2, float>::value || std::is_same<T2, double>::value,
|
||||
static_assert(is_same<T2, float>::value || is_same<T2, double>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
using ck::type_convert;
|
||||
|
||||
@@ -252,7 +252,7 @@ struct PassThroughPack2
|
||||
template <typename Y, typename X>
|
||||
__host__ __device__ void operator()(Y& y, const X& x) const;
|
||||
|
||||
__host__ __device__ constexpr void operator()(ck::half2_t& y, const ck::f8x2_t& x) const
|
||||
__host__ __device__ constexpr void operator()(half2_t& y, const f8x2_t& x) const
|
||||
{
|
||||
auto t = type_convert<float2_t>(x);
|
||||
y = type_convert<half2_t>(t);
|
||||
@@ -479,7 +479,7 @@ struct PassThrough
|
||||
template <>
|
||||
__host__ __device__ void operator()<bf8_t, half_t>(bf8_t& y, const half_t& x) const
|
||||
{
|
||||
y = ck::type_convert<bf8_t>(x);
|
||||
y = type_convert<bf8_t>(x);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -552,21 +552,21 @@ struct Scale
|
||||
template <typename Y, typename X>
|
||||
__host__ __device__ void operator()(Y& y, const X& x) const
|
||||
{
|
||||
y = ck::type_convert<Y>(ck::type_convert<float>(x) * scale_);
|
||||
y = type_convert<Y>(type_convert<float>(x) * scale_);
|
||||
}
|
||||
|
||||
template <>
|
||||
__host__ __device__ void operator()<half_t, half_t>(half_t& y, const half_t& x) const
|
||||
{
|
||||
y = ck::type_convert<half_t>(scale_) * x;
|
||||
y = type_convert<half_t>(scale_) * x;
|
||||
};
|
||||
|
||||
template <>
|
||||
__host__ __device__ void operator()<bhalf_t, bhalf_t>(bhalf_t& y, const bhalf_t& x) const
|
||||
{
|
||||
const float x_tmp = ck::type_convert<float>(x);
|
||||
const float x_tmp = type_convert<float>(x);
|
||||
const float y_tmp = scale_ * x_tmp;
|
||||
y = ck::type_convert<bhalf_t>(y_tmp);
|
||||
y = type_convert<bhalf_t>(y_tmp);
|
||||
};
|
||||
|
||||
template <>
|
||||
@@ -584,7 +584,7 @@ struct Scale
|
||||
template <>
|
||||
__host__ __device__ void operator()<int8_t, int8_t>(int8_t& y, const int8_t& x) const
|
||||
{
|
||||
y = ck::type_convert<int8_t>(scale_ * ck::type_convert<float>(x));
|
||||
y = type_convert<int8_t>(scale_ * type_convert<float>(x));
|
||||
};
|
||||
|
||||
float scale_;
|
||||
@@ -600,7 +600,7 @@ struct ScaleAndResetNaNToMinusInfinity
|
||||
template <>
|
||||
__host__ __device__ void operator()<float, float>(float& y, const float& x) const
|
||||
{
|
||||
y = ck::math::isnan(x) ? -ck::NumericLimits<float>::Infinity() : scale_ * x;
|
||||
y = math::isnan(x) ? -NumericLimits<float>::Infinity() : scale_ * x;
|
||||
};
|
||||
|
||||
float scale_;
|
||||
@@ -671,12 +671,13 @@ struct UnaryAbs
|
||||
template <typename T>
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int32_t>::value ||
|
||||
is_same<T, int8_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::abs(x);
|
||||
y = math::abs(x);
|
||||
};
|
||||
|
||||
template <>
|
||||
@@ -694,7 +695,7 @@ struct UnarySqrt
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::sqrt(x);
|
||||
y = math::sqrt(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -713,9 +714,9 @@ struct Relu
|
||||
template <>
|
||||
__host__ __device__ void operator()(bhalf_t& y, const bhalf_t& x) const
|
||||
{
|
||||
float x_f32 = ck::type_convert<float>(x);
|
||||
float x_f32 = type_convert<float>(x);
|
||||
float y_f32 = x_f32 > 0 ? x_f32 : 0;
|
||||
y = ck::type_convert<bhalf_t>(y_f32);
|
||||
y = type_convert<bhalf_t>(y_f32);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -731,7 +732,7 @@ struct FastGelu
|
||||
|
||||
template <typename Y, typename X>
|
||||
__device__ void operator()(Y& y, const X& x) const;
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
template <>
|
||||
__host__ void operator()<float, float>(float& y, const float& x) const
|
||||
{
|
||||
@@ -742,6 +743,7 @@ struct FastGelu
|
||||
const float emu = exp(u);
|
||||
y = x / (1.f + emu);
|
||||
}
|
||||
#endif
|
||||
|
||||
// device code, use lower precision "__ocml_exp_f32" and "rcp"
|
||||
template <>
|
||||
@@ -753,7 +755,7 @@ struct FastGelu
|
||||
const float u = x * (c1 * x * x + c2);
|
||||
const float emu = __ocml_exp_f32(u);
|
||||
|
||||
y = x * ck::math::rcp(1.f + emu);
|
||||
y = x * math::rcp(1.f + emu);
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -851,10 +853,9 @@ struct Gelu
|
||||
}
|
||||
|
||||
template <>
|
||||
__host__ __device__ void operator()<ck::half_t, ck::half_t>(ck::half_t& y,
|
||||
const ck::half_t& x) const
|
||||
__host__ __device__ void operator()<half_t, half_t>(half_t& y, const half_t& x) const
|
||||
{
|
||||
y = ck::half_t(0.5) * x * (ck::half_t(1) + ck::half_t(erf(float(0.70710678118f * x))));
|
||||
y = half_t(0.5) * x * (half_t(1) + half_t(erf(float(0.70710678118f * x))));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -868,7 +869,7 @@ struct Sigmoid
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
constexpr T one = type_convert<T>(1);
|
||||
y = one / (one + ck::math::exp(-x));
|
||||
y = one / (one + math::exp(-x));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -877,11 +878,11 @@ struct Silu
|
||||
template <typename T>
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same_v<T, float> || is_same_v<T, double> || is_same_v<T, ck::half_t> ||
|
||||
static_assert(is_same_v<T, float> || is_same_v<T, double> || is_same_v<T, half_t> ||
|
||||
is_same_v<T, int8_t> || is_same_v<T, int32_t>,
|
||||
"Data type is not supported by this operation!");
|
||||
constexpr T one = type_convert<T>(1);
|
||||
y = x * (one / (one + ck::math::exp(-x)));
|
||||
y = x * (one / (one + math::exp(-x)));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -895,7 +896,7 @@ struct TanH
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::tanh(x);
|
||||
y = math::tanh(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -905,11 +906,11 @@ struct ACos
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::acos(x);
|
||||
y = math::acos(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -919,11 +920,11 @@ struct Neg
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::neg(x);
|
||||
y = math::neg(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -933,11 +934,11 @@ struct ATan
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::atan(x);
|
||||
y = math::atan(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -947,11 +948,11 @@ struct Sin
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::sin(x);
|
||||
y = math::sin(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -961,11 +962,11 @@ struct ASinH
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::asinh(x);
|
||||
y = math::asinh(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -975,11 +976,11 @@ struct Cos
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::cos(x);
|
||||
y = cos(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -989,11 +990,11 @@ struct ACosH
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::acosh(x);
|
||||
y = math::acosh(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1003,11 +1004,11 @@ struct Tan
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::tan(x);
|
||||
y = math::tan(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1017,11 +1018,11 @@ struct ATanH
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::atanh(x);
|
||||
y = math::atanh(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1031,11 +1032,11 @@ struct SinH
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::sinh(x);
|
||||
y = math::sinh(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1045,11 +1046,11 @@ struct Ceil
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::ceil(x);
|
||||
y = math::ceil(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1059,11 +1060,11 @@ struct Exp
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::exp(x);
|
||||
y = math::exp(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1073,11 +1074,11 @@ struct CosH
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::cosh(x);
|
||||
y = math::cosh(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1087,11 +1088,11 @@ struct Floor
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::floor(x);
|
||||
y = math::floor(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1101,11 +1102,11 @@ struct Log
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::log(x);
|
||||
y = math::log(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1115,11 +1116,11 @@ struct ASin
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::asin(x);
|
||||
y = math::asin(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1129,11 +1130,11 @@ struct Rcp
|
||||
__host__ __device__ void operator()(T& y, const T& x) const
|
||||
{
|
||||
static_assert(is_same<T, float>::value || is_same<T, double>::value ||
|
||||
is_same<T, ck::half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, half_t>::value || is_same<T, int8_t>::value ||
|
||||
is_same<T, int32_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
y = ck::math::rcp(x);
|
||||
y = math::rcp(x);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1153,7 +1154,7 @@ struct Swish
|
||||
"Data type is not supported by this operation!");
|
||||
|
||||
float bx = -beta_ * type_convert<float>(x);
|
||||
y = type_convert<Y>(x / (1.f + ck::math::exp(bx)));
|
||||
y = type_convert<Y>(x / (1.f + math::exp(bx)));
|
||||
};
|
||||
|
||||
const float beta_;
|
||||
@@ -1172,7 +1173,7 @@ struct SoftRelu
|
||||
"Data type is not supported by this operation!");
|
||||
T casted_alpha = type_convert<T>(alpha_);
|
||||
constexpr T one = type_convert<T>(1);
|
||||
y = ck::math::log(one + ck::math::exp(x * casted_alpha)) / casted_alpha;
|
||||
y = math::log(one + math::exp(x * casted_alpha)) / casted_alpha;
|
||||
}
|
||||
const float alpha_;
|
||||
};
|
||||
@@ -1193,7 +1194,7 @@ struct Power
|
||||
T casted_beta = type_convert<T>(beta_);
|
||||
T casted_gamma = type_convert<T>(gamma_);
|
||||
T shifted_scaled_x = casted_alpha + casted_beta * x;
|
||||
y = ck::math::pow(shifted_scaled_x, casted_gamma);
|
||||
y = math::pow(shifted_scaled_x, casted_gamma);
|
||||
}
|
||||
const float alpha_;
|
||||
const float beta_;
|
||||
@@ -1213,7 +1214,7 @@ struct ClippedRelu
|
||||
"Data type is not supported by this operation!");
|
||||
T casted_alpha = type_convert<T>(alpha_);
|
||||
T casted_beta = type_convert<T>(beta_);
|
||||
y = ck::math::min(casted_beta, ck::math::max(casted_alpha, x));
|
||||
y = math::min(casted_beta, math::max(casted_alpha, x));
|
||||
}
|
||||
const float alpha_;
|
||||
const float beta_;
|
||||
@@ -1248,7 +1249,7 @@ struct Elu
|
||||
is_same<T, int8_t>::value,
|
||||
"Data type is not supported by this operation!");
|
||||
T casted_alpha = type_convert<T>(alpha_);
|
||||
y = x > 0 ? x : casted_alpha * ck::math::expm1(x);
|
||||
y = x > 0 ? x : casted_alpha * math::expm1(x);
|
||||
}
|
||||
const float alpha_;
|
||||
};
|
||||
@@ -1350,10 +1351,10 @@ struct FastNumericArrayConverter
|
||||
};
|
||||
|
||||
template <>
|
||||
struct FastNumericArrayConverter<uint8_t, ck::half_t, 4>
|
||||
struct FastNumericArrayConverter<uint8_t, half_t, 4>
|
||||
{
|
||||
using InputArray = vector_type<uint8_t, 4>;
|
||||
using OutputArray = vector_type<ck::half_t, 4>;
|
||||
using OutputArray = vector_type<half_t, 4>;
|
||||
|
||||
__device__ static OutputArray convert(InputArray const& Input)
|
||||
{
|
||||
@@ -1383,13 +1384,13 @@ struct FastNumericArrayConverter<uint8_t, ck::half_t, 4>
|
||||
};
|
||||
|
||||
template <index_t N>
|
||||
struct FastNumericArrayConverter<uint8_t, ck::half_t, N>
|
||||
struct FastNumericArrayConverter<uint8_t, half_t, N>
|
||||
{
|
||||
static constexpr int VEC_WIDTH = 4;
|
||||
static_assert(!(N % VEC_WIDTH), "N must be multiple of 4.");
|
||||
|
||||
using InputArray = vector_type<uint8_t, N>;
|
||||
using OutputArray = vector_type<ck::half_t, N>;
|
||||
using OutputArray = vector_type<half_t, N>;
|
||||
|
||||
__device__ static OutputArray convert(InputArray const& Input)
|
||||
{
|
||||
@@ -1398,7 +1399,7 @@ struct FastNumericArrayConverter<uint8_t, ck::half_t, N>
|
||||
OutputArray Output;
|
||||
|
||||
using Vec_InputArray = vector_type<uint8_t, 4>;
|
||||
using Vec_OutputArray = vector_type<ck::half_t, 4>;
|
||||
using Vec_OutputArray = vector_type<half_t, 4>;
|
||||
|
||||
Vec_OutputArray* half_4_ptr = reinterpret_cast<Vec_OutputArray*>(&Output);
|
||||
Vec_InputArray const* uint8_4_ptr = reinterpret_cast<Vec_InputArray const*>(&Input);
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ck/utility/math.hpp"
|
||||
#include "ck/utility/number.hpp"
|
||||
#include "ck/utility/tuple.hpp"
|
||||
#include "ck/tensor_description/tensor_adaptor.hpp"
|
||||
#include "ck/tensor_description/multi_index_transform_helper.hpp"
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
#include <limits>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
namespace ck {
|
||||
|
||||
@@ -978,8 +981,7 @@ struct BlockToCTileMap_3DGrid_KSplit
|
||||
// Create 3D grid
|
||||
const auto M0 = math::integer_divide_ceil(M, MPerBlock);
|
||||
const auto N0 = math::integer_divide_ceil(N, NPerBlock);
|
||||
|
||||
return std::make_tuple(N0, M0, k_split);
|
||||
return make_tuple(N0, M0, k_split);
|
||||
}
|
||||
|
||||
template <typename TopIdx>
|
||||
@@ -1103,7 +1105,7 @@ struct BlockToCTileMap_GemmStreamK
|
||||
uint32_t dp_for_sk_iters = k_iters_per_tile.get();
|
||||
|
||||
uint32_t best_sk_score =
|
||||
std::numeric_limits<int>::max(); // we need to find the smallest sk iters
|
||||
NumericLimits<int32_t>::Max(); // we need to find the smallest sk iters
|
||||
for(uint32_t tentative_sk_blocks = min_sk_tiles; tentative_sk_blocks < max_sk_tiles;
|
||||
tentative_sk_blocks++)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -423,10 +423,17 @@ struct GridwiseGemmMultipleABD_xdl_cshuffle
|
||||
}
|
||||
|
||||
template <typename AsLayout, GemmSpecialization GemmSpec>
|
||||
__host__ __device__ static auto
|
||||
MakeAsGridDescriptor_M_K(const std::array<index_t, NumATensor>& MRaws,
|
||||
const std::array<index_t, NumATensor>& KRaws,
|
||||
const std::array<index_t, NumATensor>& AsStride)
|
||||
__host__ __device__ static auto MakeAsGridDescriptor_M_K(
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
const ck::Array<index_t, NumATensor>& MRaws,
|
||||
const ck::Array<index_t, NumATensor>& KRaws,
|
||||
const ck::Array<index_t, NumATensor>& AsStride
|
||||
#else
|
||||
const std::array<index_t, NumATensor>& MRaws,
|
||||
const std::array<index_t, NumATensor>& KRaws,
|
||||
const std::array<index_t, NumATensor>& AsStride
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return generate_tuple(
|
||||
[&](auto i) {
|
||||
@@ -462,10 +469,17 @@ struct GridwiseGemmMultipleABD_xdl_cshuffle
|
||||
}
|
||||
|
||||
template <typename BsLayout, GemmSpecialization GemmSpec>
|
||||
__host__ __device__ static auto
|
||||
MakeBsGridDescriptor_N_K(const std::array<index_t, NumBTensor>& NRaws,
|
||||
const std::array<index_t, NumBTensor>& KRaws,
|
||||
const std::array<index_t, NumBTensor>& BsStride)
|
||||
__host__ __device__ static auto MakeBsGridDescriptor_N_K(
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
const ck::Array<index_t, NumBTensor>& NRaws,
|
||||
const ck::Array<index_t, NumBTensor>& KRaws,
|
||||
const ck::Array<index_t, NumBTensor>& BsStride
|
||||
#else
|
||||
const std::array<index_t, NumBTensor>& NRaws,
|
||||
const std::array<index_t, NumBTensor>& KRaws,
|
||||
const std::array<index_t, NumBTensor>& BsStride
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return generate_tuple(
|
||||
[&](auto i) {
|
||||
@@ -500,10 +514,17 @@ struct GridwiseGemmMultipleABD_xdl_cshuffle
|
||||
}
|
||||
|
||||
template <typename DsLayout, GemmSpecialization GemmSpec>
|
||||
__host__ __device__ static auto
|
||||
MakeDsGridDescriptor_M_N(const std::array<index_t, NumDTensor>& MRaws,
|
||||
const std::array<index_t, NumDTensor>& NRaws,
|
||||
const std::array<index_t, NumDTensor>& DsStride)
|
||||
__host__ __device__ static auto MakeDsGridDescriptor_M_N(
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
const ck::Array<index_t, NumDTensor>& MRaws,
|
||||
const ck::Array<index_t, NumDTensor>& NRaws,
|
||||
const ck::Array<index_t, NumDTensor>& DsStride
|
||||
#else
|
||||
const std::array<index_t, NumDTensor>& MRaws,
|
||||
const std::array<index_t, NumDTensor>& NRaws,
|
||||
const std::array<index_t, NumDTensor>& DsStride
|
||||
#endif
|
||||
)
|
||||
{
|
||||
return generate_tuple(
|
||||
[&](auto i) {
|
||||
@@ -969,9 +990,15 @@ struct GridwiseGemmMultipleABD_xdl_cshuffle
|
||||
const index_t M,
|
||||
const index_t N,
|
||||
const index_t K,
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
const ck::Array<index_t, NumATensor> StrideAs,
|
||||
const ck::Array<index_t, NumBTensor> StrideBs,
|
||||
const ck::Array<index_t, NumDTensor> StrideDs,
|
||||
#else
|
||||
const std::array<index_t, NumATensor> StrideAs,
|
||||
const std::array<index_t, NumBTensor> StrideBs,
|
||||
const std::array<index_t, NumDTensor> StrideDs,
|
||||
#endif
|
||||
const index_t StrideE,
|
||||
const Block2ETileMap& block_2_etile_map)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -473,11 +473,19 @@ struct GridwiseGemmMultipleD_xdl_cshuffle
|
||||
return matrix_padder.PadCDescriptor_M_N(e_grid_desc_mraw_nraw);
|
||||
}
|
||||
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
template <typename DsLayout, GemmSpecialization GemmSpec>
|
||||
__host__ __device__ static auto
|
||||
MakeDsGridDescriptor_M_N(const ck::Array<index_t, NumDTensor>& MRaws,
|
||||
const ck::Array<index_t, NumDTensor>& NRaws,
|
||||
const ck::Array<index_t, NumDTensor>& DsStride)
|
||||
#else
|
||||
template <typename DsLayout, GemmSpecialization GemmSpec>
|
||||
__host__ __device__ static auto
|
||||
MakeDsGridDescriptor_M_N(const std::array<index_t, NumDTensor>& MRaws,
|
||||
const std::array<index_t, NumDTensor>& NRaws,
|
||||
const std::array<index_t, NumDTensor>& DsStride)
|
||||
#endif
|
||||
{
|
||||
return generate_tuple(
|
||||
[&](auto i) {
|
||||
@@ -941,7 +949,11 @@ struct GridwiseGemmMultipleD_xdl_cshuffle
|
||||
const index_t K,
|
||||
const index_t StrideA,
|
||||
const index_t StrideB,
|
||||
#ifdef CK_CODE_GEN_RTC
|
||||
const ck::Array<index_t, NumDTensor> StrideDs,
|
||||
#else
|
||||
const std::array<index_t, NumDTensor> StrideDs,
|
||||
#endif
|
||||
const index_t StrideE,
|
||||
const Block2ETileMap& block_2_etile_map)
|
||||
{
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2024, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#endif
|
||||
|
||||
#include "ck/tensor_operation/gpu/grid/gridwise_gemm_pipeline_v1.hpp"
|
||||
#include "ck/tensor_operation/gpu/grid/gridwise_gemm_pipeline_v2.hpp"
|
||||
@@ -53,12 +54,15 @@ constexpr auto GridwiseGemmPipeline_Selector()
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
std::cerr << "GridwiseGemmPipeline configuration is not available" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ck
|
||||
|
||||
#ifndef CK_CODE_GEN_RTC
|
||||
inline std::ostream& operator<<(std::ostream& os, const ck::PipelineVersion& p)
|
||||
{
|
||||
switch(p)
|
||||
@@ -71,3 +75,4 @@ inline std::ostream& operator<<(std::ostream& os, const ck::PipelineVersion& p)
|
||||
}
|
||||
return os;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
|
||||
// Copyright (c) 2018-2025, Advanced Micro Devices, Inc. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -212,7 +212,7 @@ template <typename SrcData,
|
||||
typename enable_if<DstDesc::IsKnownAtCompileTime(), bool>::type = false>
|
||||
struct ThreadwiseTensorSliceTransfer_v2
|
||||
{
|
||||
static_assert((InvalidElementAsNaN && !std::is_integral<DstData>::value) ||
|
||||
static_assert((InvalidElementAsNaN && !ck::is_integral<DstData>::value) ||
|
||||
(!InvalidElementAsNaN),
|
||||
"Filling invalid element as NaN is only for floating point types");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user