mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-01 20:21: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-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);
|
||||
|
||||
Reference in New Issue
Block a user