35template <
typename Shape,
typename UnrolledDescriptorType>
40 typename UnrolledDescriptorType>
43template <
typename FromType,
typename ToType>
46 __host__ __device__
constexpr Slice() : from_(), to_() {}
47 __host__ __device__
constexpr Slice(FromType from, ToType to) : from_(from), to_(to) {}
56 __host__ __device__
constexpr auto range(
const T& dim)
const
58 if constexpr(is_same_v<FromType, index_t> || is_same_v<ToType, index_t> ||
59 is_same_v<std::remove_const_t<T>,
index_t>)
63 return dim - from_ + to_ + 1;
73 static_assert(T{} >= ToType{} && FromType{} >= Number<0>{} &&
74 (ToType{} < 0 || ToType{} > FromType{}),
76 if constexpr(ToType{} < 0)
78 return dim - from_ + to_ + Number<1>{};
87 __host__ __device__
static constexpr bool IsSlice() {
return true; }
94using is_slice =
decltype(std::declval<T&>().IsSlice());
97using is_tuple =
decltype(std::declval<T&>().IsTuple());
109 typename ElementType,
111 typename UnrolledDescriptorType>
126 typename ElementType,
128 typename UnrolledDescriptorType>
140 typename ElementType,
142 typename UnrolledDescriptorType>
143__host__ __device__
void
158 typename ElementType,
160 typename UnrolledDescriptorType>
161__host__ __device__
constexpr const auto&
176 typename ElementType,
178 typename UnrolledDescriptorType>
179__host__ __device__
constexpr auto
182 return size<Idxs...>(tensor.
GetLayout());
194 typename ElementType,
196 typename UnrolledDescriptorType>
197__host__ __device__
constexpr auto
212 typename ElementType,
214 typename UnrolledDescriptorType>
215__host__ __device__
constexpr auto
228 typename ElementType,
230 typename UnrolledDescriptorType>
231__host__ __device__
constexpr const auto&
244template <
typename FromType,
typename ToType>
245constexpr auto slice(
const FromType from,
const ToType to)
247 return Slice<FromType, ToType>(from, to);
256template <
typename ToType>
257constexpr auto slice(
const ToType to)
259 if constexpr(is_same_v<ToType, index_t>)
261 return Slice<index_t, ToType>(0, to);
265 return Slice<Number<0>, ToType>(Number<0>{}, to);
274constexpr auto slice() {
return Slice<Number<0>, Number<-1>>(Number<0>{}, Number<-1>{}); }
__host__ __device__ constexpr const auto & shape(const LayoutType &layout)
Get Layout shape.
Definition layout_utils.hpp:431
__host__ __device__ constexpr auto depth(const Layout< Shape, UnrolledDescriptorType > &layout)
Get depth of the layout shape (return 0 if scalar).
Definition layout_utils.hpp:371
__host__ __device__ constexpr auto rank(const Layout< Shape, UnrolledDescriptorType > &layout)
Get layout rank (num elements in shape).
Definition layout_utils.hpp:310
decltype(std::declval< T & >().IsTuple()) is_tuple
Definition device_grouped_conv_fwd_multiple_abd.hpp:23
int32_t index_t
Definition ck.hpp:299
const GenericPointer< typename T::ValueType > & pointer
Definition pointer.h:1514
Layout wrapper that performs the tensor descriptor logic.
Definition layout.hpp:24
Tensor wrapper that performs static and dynamic buffer logic. The tensor is based on a descriptor sto...
Definition library/utility/host_tensor.hpp:694
__host__ __device__ constexpr const Layout< Shape, UnrolledDescriptorType > & GetLayout() const
Definition tensor.hpp:246
static constexpr bool IsDynamicBuffer
Definition tensor.hpp:224
__host__ __device__ constexpr auto & GetBuffer()
Definition tensor.hpp:380
constexpr auto slice()
Get whole dim slice (from = 0, to = -1).
Definition tensor_utils.hpp:274
__host__ __device__ constexpr const auto & layout(const Tensor< BufferAddressSpace, ElementType, Shape, UnrolledDescriptorType > &tensor)
Get Tensor Layout.
Definition tensor_utils.hpp:162
__host__ __device__ void clear(Tensor< BufferAddressSpace, ElementType, Shape, UnrolledDescriptorType > &tensor)
Clear tensor. (Only for Vpgr/Sgpr).
Definition tensor_utils.hpp:144
AddressSpaceEnum MemoryTypeEnum
Memory type, allowed members:
Definition tensor_utils.hpp:30
constexpr auto make_register_tensor(const Layout< Shape, UnrolledDescriptorType > &layout)
Make SGPR or VGPR tensor function.
Definition tensor_utils.hpp:129
constexpr auto make_tensor(ElementType *pointer, const Layout< Shape, UnrolledDescriptorType > &layout)
Make tensor function.
Definition tensor_utils.hpp:112