mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-12 17:26:00 +00:00
* Squashed 'src/composable_kernel/' content from commitf6edda611git-subtree-dir: src/composable_kernel git-subtree-split:f6edda6119* add solver ConvIgemmFwdV6r1DlopsNchwKcyxNkhw; rename static ck source files * Squashed 'src/composable_kernel/' changes from f6edda611..5781adf5c5781adf5cUpdate develop (#5) (#6)97e6d514fMerge pull request #4 from ROCmSoftwarePlatform/separate_online_compile7b1ec41e5refactor49c33aaearefactor54b3e73d1rename git-subtree-dir: src/composable_kernel git-subtree-split:5781adf5cf* fix * refactor * remove online compilation from CK * refactor * fix * add ctest * add c-style pointer cast * vector/scalar pointer cast use c-style pointer cast instead of reinterpret_cast * fix clang warning suppression * tidy * suppress cppcheck * fix enum issue * revert chagnes to hip build * fix kernel filename * update CK build script * rename * rename * make innner product compatiable on gfx900 * Update src/include/miopen/solver/ck_utility_common.hpp Co-authored-by: JD <Jehandad.Khan@amd.com> * compiler parameter use stream * use int instead of index_t in kernel wrapper * DynamicBuffer, StaticBuffer, amd_buffer_load support customized value for invalid element * refactor * refactor * change cmakelist * change ck common utility * fix Co-authored-by: JD <Jehandad.Khan@amd.com>
87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
#ifndef CONV_COMMON_HPP
|
|
#define CONV_COMMON_HPP
|
|
|
|
#include "tensor_descriptor.hpp"
|
|
|
|
enum ConvTensorLayout
|
|
{
|
|
NCHW,
|
|
NHWC,
|
|
CHWN,
|
|
NCHWc,
|
|
NHWCc
|
|
};
|
|
|
|
template <typename... InDesc,
|
|
typename... WeiDesc,
|
|
typename ConvStrides,
|
|
typename ConvDilations,
|
|
typename LeftPads,
|
|
typename RightPads>
|
|
constexpr auto get_convolution_output_default_4d_tensor_descriptor(
|
|
const ck::TensorDescriptor<InDesc...>& in_desc,
|
|
const ck::TensorDescriptor<WeiDesc...>& wei_desc,
|
|
const ConvStrides& conv_strides,
|
|
const ConvDilations conv_dilations,
|
|
const LeftPads& left_pads,
|
|
const RightPads& right_pads)
|
|
{
|
|
using namespace ck;
|
|
|
|
constexpr auto I0 = Number<0>{};
|
|
constexpr auto I1 = Number<1>{};
|
|
constexpr auto I2 = Number<2>{};
|
|
constexpr auto I3 = Number<3>{};
|
|
|
|
assert(in_desc.GetNumOfDimension() == 4);
|
|
assert(wei_desc.GetNumOfDimension() == 4);
|
|
assert(in_desc.GetLength(I1) == wei_desc.GetLength(I1));
|
|
|
|
const auto N = in_desc.GetLength(I0);
|
|
const auto Hi = in_desc.GetLength(I2);
|
|
const auto Wi = in_desc.GetLength(I3);
|
|
|
|
const auto K = wei_desc.GetLength(I0);
|
|
const auto Y = wei_desc.GetLength(I2);
|
|
const auto X = wei_desc.GetLength(I3);
|
|
|
|
const auto LeftPadH = left_pads[I0];
|
|
const auto LeftPadW = left_pads[I1];
|
|
|
|
const auto RightPadH = right_pads[I0];
|
|
const auto RightPadW = right_pads[I1];
|
|
|
|
const auto YEff = (Y - I1) * conv_dilations[I0] + I1;
|
|
const auto XEff = (X - I1) * conv_dilations[I1] + I1;
|
|
|
|
const auto Ho = (Hi + LeftPadH + RightPadH - YEff) / conv_strides[I0] + I1;
|
|
const auto Wo = (Wi + LeftPadW + RightPadW - XEff) / conv_strides[I1] + I1;
|
|
|
|
return make_naive_tensor_descriptor_packed(make_tuple(N, K, Ho, Wo));
|
|
}
|
|
|
|
template <class InDesc, class WeiDesc, class OutDesc>
|
|
constexpr std::size_t
|
|
calculate_convolution_flops(const InDesc&, const WeiDesc& wei_desc, const OutDesc& out_desc)
|
|
{
|
|
using namespace ck;
|
|
|
|
constexpr auto I0 = Number<0>{};
|
|
constexpr auto I1 = Number<1>{};
|
|
constexpr auto I2 = Number<2>{};
|
|
constexpr auto I3 = Number<3>{};
|
|
|
|
const index_t N = out_desc.GetLength(I0);
|
|
const index_t K = out_desc.GetLength(I1);
|
|
const index_t Ho = out_desc.GetLength(I2);
|
|
const index_t Wo = out_desc.GetLength(I3);
|
|
|
|
const index_t C = wei_desc.GetLength(I1);
|
|
const index_t Y = wei_desc.GetLength(I2);
|
|
const index_t X = wei_desc.GetLength(I3);
|
|
|
|
return std::size_t(2) * N * K * Ho * Wo * C * Y * X;
|
|
}
|
|
|
|
#endif
|