mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-12 09:16:52 +00:00
CK: Remove 41 commented-out dead code blocks (~200 lines) (#6302) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Depends on #6300 ## Summary Remove 41 commented-out code blocks across 33 files in Composable Kernel, totaling ~200 lines. Identified using an automated dead code scanning skill (`ck-dead-code`) with a calibrated two-stage pipeline: 1. **Pre-filter**: Keyword-based scan found 1,338 `//`-commented blocks. Calibrated heuristics (trained on 50-sample expert classification) reduced to 89 high-confidence candidates — 93% noise reduction. 2. **Expert triage**: LLM expert classified each block in context as CODE_REMOVE, CODE_KEEP, or NOT_CODE. | Classification | Count | |---------------|-------| | Removed (this PR) | 41 | | Kept (debug helpers, alt configs, reference impls) | 32 | | Not code (false positives) | 16 | Removed blocks include: superseded implementations, old test data, abandoned stubs, unreachable code, and buggy dead code.
153 lines
4.0 KiB
C++
153 lines
4.0 KiB
C++
// Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#ifndef CK_CONTAINER_ELEMENT_PICKER_HPP
|
|
#define CK_CONTAINER_ELEMENT_PICKER_HPP
|
|
|
|
#include "functional2.hpp"
|
|
#include "sequence.hpp"
|
|
|
|
namespace ck {
|
|
|
|
// Arr: Array or StaticallyIndexedArray
|
|
// Picks: Sequence<...>
|
|
template <typename Arr, typename Picks>
|
|
struct ContainerElementPicker
|
|
{
|
|
using type = ContainerElementPicker;
|
|
|
|
__host__ __device__ constexpr ContainerElementPicker() = delete;
|
|
|
|
__host__ __device__ constexpr ContainerElementPicker(Arr& array) : mArray{array}
|
|
{
|
|
constexpr index_t imax =
|
|
reduce_on_sequence(Picks{}, math::maximize<index_t>{}, Number<0>{});
|
|
|
|
static_assert(imax < Arr::Size(), "wrong! exceeding # array element");
|
|
}
|
|
|
|
__host__ __device__ static constexpr auto Size() { return Picks::Size(); }
|
|
|
|
template <index_t I>
|
|
__host__ __device__ constexpr const auto& At(Number<I> i) const
|
|
{
|
|
static_assert(I < Size(), "wrong!");
|
|
|
|
constexpr auto IP = Picks{}[i];
|
|
return mArray[IP];
|
|
}
|
|
|
|
template <index_t I>
|
|
__host__ __device__ constexpr auto& At(Number<I> i)
|
|
{
|
|
static_assert(I < Size(), "wrong!");
|
|
|
|
constexpr auto IP = Picks{}[i];
|
|
return mArray(IP);
|
|
}
|
|
|
|
template <index_t I>
|
|
__host__ __device__ constexpr const auto& operator[](Number<I> i) const
|
|
{
|
|
return At(i);
|
|
}
|
|
|
|
template <index_t I>
|
|
__host__ __device__ constexpr auto& operator()(Number<I> i)
|
|
{
|
|
return At(i);
|
|
}
|
|
|
|
template <typename T>
|
|
__host__ __device__ constexpr auto operator=(const T& a)
|
|
{
|
|
static_assert(T::Size() == Size(), "wrong! size not the same");
|
|
|
|
static_for<0, Size(), 1>{}([&](auto i) { operator()(i) = a[i]; });
|
|
|
|
return *this;
|
|
}
|
|
|
|
private:
|
|
Arr& mArray;
|
|
};
|
|
|
|
// Arr: Array or StaticallyIndexedArray
|
|
// Picks: Sequence<...>
|
|
template <typename Arr, typename Picks>
|
|
struct ConstantContainerElementPicker
|
|
{
|
|
using type = ConstantContainerElementPicker;
|
|
|
|
__host__ __device__ constexpr ConstantContainerElementPicker() = delete;
|
|
|
|
__host__ __device__ constexpr ConstantContainerElementPicker(const Arr& array) : mArray{array}
|
|
{
|
|
constexpr index_t imax =
|
|
reduce_on_sequence(Picks{}, math::maximize<index_t>{}, Number<0>{});
|
|
|
|
static_assert(imax < Arr::Size(), "wrong! exceeding # array element");
|
|
}
|
|
|
|
__host__ __device__ static constexpr auto Size() { return Picks::Size(); }
|
|
|
|
template <index_t I>
|
|
__host__ __device__ constexpr const auto& At(Number<I> i) const
|
|
{
|
|
static_assert(I < Size(), "wrong!");
|
|
|
|
constexpr auto IP = Picks{}[i];
|
|
return mArray[IP];
|
|
}
|
|
|
|
template <index_t I>
|
|
__host__ __device__ constexpr const auto& operator[](Number<I> i) const
|
|
{
|
|
return At(i);
|
|
}
|
|
|
|
private:
|
|
const Arr& mArray;
|
|
};
|
|
|
|
template <typename Arr, typename Picks, typename X>
|
|
__host__ __device__ constexpr auto operator+=(ContainerElementPicker<Arr, Picks>& y, const X& x)
|
|
{
|
|
using Y = ContainerElementPicker<Arr, Picks>;
|
|
constexpr index_t nsize = Y::Size();
|
|
|
|
static_assert(nsize == X::Size(), "wrong! size not the same");
|
|
|
|
static_for<0, nsize, 1>{}([&](auto i) { y(i) += x[i]; });
|
|
|
|
return y;
|
|
}
|
|
|
|
template <typename Arr, typename Picks, typename X>
|
|
__host__ __device__ constexpr auto operator-=(ContainerElementPicker<Arr, Picks>& y, const X& x)
|
|
{
|
|
using Y = ContainerElementPicker<Arr, Picks>;
|
|
constexpr index_t nsize = Y::Size();
|
|
|
|
static_assert(nsize == X::Size(), "wrong! size not the same");
|
|
|
|
static_for<0, nsize, 1>{}([&](auto i) { y(i) -= x[i]; });
|
|
|
|
return y;
|
|
}
|
|
|
|
template <typename Arr, typename Picks>
|
|
__host__ __device__ constexpr auto pick_container_element(Arr& a, Picks)
|
|
{
|
|
return ContainerElementPicker<Arr, Picks>(a);
|
|
}
|
|
|
|
template <typename Arr, typename Picks>
|
|
__host__ __device__ constexpr auto pick_container_element(const Arr& a, Picks)
|
|
{
|
|
return ConstantContainerElementPicker<Arr, Picks>(a);
|
|
}
|
|
|
|
} // namespace ck
|
|
#endif
|