detail Namespace Reference#
8 min read time
Namespaces | |
math | |
Classes | |
struct | HasTypeTraits_t |
struct | MakeType_t |
class | StridedDataWrap |
struct | SwizzleIndexMap |
struct | SwizzleIndexMap< eSwizzle::XYZW, N > |
struct | SwizzleIndexMap< eSwizzle::ZYXW, 1 > |
struct | SwizzleIndexMap< eSwizzle::ZYXW, 3 > |
struct | SwizzleIndexMap< eSwizzle::ZYXW, 4 > |
struct | TypeTraits |
Returns the type traits associated with a datatype. More... | |
Typedefs | |
template<typename T > | |
using | BaseType = typename TypeTraits< T >::base_type |
Returns the base type of a given HIP vectorized type. More... | |
template<typename T , int C> | |
using | MakeType = MakeType_t< T, C >::type |
Functions | |
DEFINE_TYPE_TRAITS_0_TO_4 (char, signed char) | |
DEFINE_TYPE_TRAITS_0_TO_4 (double, double) | |
DEFINE_TYPE_TRAITS_0_TO_4 (float, float) | |
DEFINE_TYPE_TRAITS_0_TO_4 (int, signed int) | |
DEFINE_TYPE_TRAITS_0_TO_4 (short, signed short) | |
DEFINE_TYPE_TRAITS_0_TO_4 (uchar, unsigned char) | |
DEFINE_TYPE_TRAITS_0_TO_4 (uint, unsigned int) | |
DEFINE_TYPE_TRAITS_0_TO_4 (ushort, unsigned short) | |
template<typename T , size_t... I> | |
__host__ constexpr __device__ T | ExpandSwizzle (const T &v, std::integer_sequence< size_t, I... >) |
template<eTensorLayout LAYOUT> | |
auto | get_sdwrapper (const roccv::Tensor &tensor) -> const StridedDataWrap< layout_get_rank< LAYOUT >()> |
template<eTensorLayout LAYOUT> | |
auto | get_sdwrapper (roccv::Tensor &tensor) -> StridedDataWrap< layout_get_rank< LAYOUT >()> |
template<> | |
auto | get_sdwrapper< TENSOR_LAYOUT_LNHWC > (const roccv::Tensor &tensor) -> const StridedDataWrap< layout_get_rank< TENSOR_LAYOUT_LNHWC >()> |
template<> | |
auto | get_sdwrapper< TENSOR_LAYOUT_NHWC > (const roccv::Tensor &tensor) -> const StridedDataWrap< layout_get_rank< TENSOR_LAYOUT_NHWC >()> |
template<> | |
auto | get_sdwrapper< TENSOR_LAYOUT_NMC > (const roccv::Tensor &tensor) -> const StridedDataWrap< layout_get_rank< TENSOR_LAYOUT_NMC >()> |
template<> | |
auto | get_sdwrapper< TENSOR_LAYOUT_NMD > (const roccv::Tensor &tensor) -> const StridedDataWrap< layout_get_rank< TENSOR_LAYOUT_NMD >()> |
template<typename T , typename RT = BaseType<T>, class = std::enable_if_t<HasTypeTraits<T>>> | |
__host__ __device__ RT & | GetElement (T &v, int idx) |
template<eTensorLayout LAYOUT> | |
constexpr size_t | layout_get_rank () |
template<> | |
constexpr size_t | layout_get_rank< TENSOR_LAYOUT_HWC > () |
template<> | |
constexpr size_t | layout_get_rank< TENSOR_LAYOUT_LNHWC > () |
template<> | |
constexpr size_t | layout_get_rank< TENSOR_LAYOUT_NHWC > () |
template<> | |
constexpr size_t | layout_get_rank< TENSOR_LAYOUT_NMC > () |
template<> | |
constexpr size_t | layout_get_rank< TENSOR_LAYOUT_NMD > () |
template<typename T , typename U , class = std::enable_if_t<(HasTypeTraits<T> && HasTypeTraits<U>) && (NumElements<T> <= NumElements<U>)>> | |
__device__ __host__ T | SaturateCast (U v) |
Performs a saturation cast from one type to another. Each type must have type traits supported. A saturation cast converts one type to another, clamping values down to the minimum/maximum of the desired cast if the value being cast goes out of bounds. For example, casting a float with a value of 256.0f to a uchar would result in a uchar with value 255. More... | |
template<typename T , typename U , class = std::enable_if_t<(HasTypeTraits<T> && HasTypeTraits<U>) && (!IsCompound<T> && !IsCompound<U>)>> | |
__device__ __host__ T | ScalarRangeCast (U v) |
ScalarRangeCast is for implementation purposes only. Use RangeCast directly instead. More... | |
template<typename T , typename U , class = std::enable_if_t<!IsCompound<T> && !IsCompound<U>>> | |
__device__ __host__ T | ScalarSaturateCast (U v) |
ScalarSaturateCast is for implementation purposes only. Use SaturateCast directly. More... | |
template<typename T , typename Base = BaseType<T>, class = std::enable_if_t<HasTypeTraits<T>>> | |
__device__ constexpr __host__ T | SetAll (Base v) |
Create a vectorized type with all values set to v. More... | |
template<eSwizzle Pattern, typename T > | |
__host__ constexpr __device__ T | Swizzle (const T &v) |
Rearranges the components of a vector according to a given swizzle pattern. More... | |
template<typename T , size_t... Indices> | |
__host__ constexpr __device__ T | SwizzleIndicesImpl (const T &v) |
Variables | |
template<typename T > | |
constexpr bool | HasTypeTraits = HasTypeTraits_t<T>::value |
Returns whether the datatype passed in has type traits associated with it. More... | |
template<typename T > | |
constexpr bool | IsCompound = TypeTraits<T>::components != 0 |
template<typename T > | |
constexpr int | NumComponents = TypeTraits<T>::components |
Returns the number of components in a given type. Scalar types will have 0 components, while vectorized types will have 1-4 components typically. More... | |
template<typename T > | |
constexpr int | NumElements = TypeTraits<T>::elements |
Returns the number of elements in a HIP vectorized type. For example: uchar3 will return 3, int2 will return 2. More... | |
Detailed Description
Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Typedef Documentation
◆ BaseType
using roccv::detail::BaseType = typedef typename TypeTraits<T>::base_type |
Returns the base type of a given HIP vectorized type.
- Template Parameters
-
T A HIP vectorized type.
◆ MakeType
using roccv::detail::MakeType = typedef MakeType_t<T, C>::type |
Function Documentation
◆ DEFINE_TYPE_TRAITS_0_TO_4() [1/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | char | , |
signed char | |||
) |
◆ DEFINE_TYPE_TRAITS_0_TO_4() [2/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | double | , |
double | |||
) |
◆ DEFINE_TYPE_TRAITS_0_TO_4() [3/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | float | , |
float | |||
) |
◆ DEFINE_TYPE_TRAITS_0_TO_4() [4/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | int | , |
signed int | |||
) |
◆ DEFINE_TYPE_TRAITS_0_TO_4() [5/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | short | , |
signed short | |||
) |
◆ DEFINE_TYPE_TRAITS_0_TO_4() [6/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | uchar | , |
unsigned char | |||
) |
◆ DEFINE_TYPE_TRAITS_0_TO_4() [7/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | uint | , |
unsigned int | |||
) |
◆ DEFINE_TYPE_TRAITS_0_TO_4() [8/8]
roccv::detail::DEFINE_TYPE_TRAITS_0_TO_4 | ( | ushort | , |
unsigned short | |||
) |
◆ ExpandSwizzle()
|
constexpr |
◆ get_sdwrapper() [1/2]
|
inline |
◆ get_sdwrapper() [2/2]
|
inline |
◆ get_sdwrapper< TENSOR_LAYOUT_LNHWC >()
|
inline |
◆ get_sdwrapper< TENSOR_LAYOUT_NHWC >()
|
inline |
◆ get_sdwrapper< TENSOR_LAYOUT_NMC >()
|
inline |
◆ get_sdwrapper< TENSOR_LAYOUT_NMD >()
|
inline |
◆ GetElement()
__host__ __device__ RT& roccv::detail::GetElement | ( | T & | v, |
int | idx | ||
) |
◆ layout_get_rank()
|
constexpr |
◆ layout_get_rank< TENSOR_LAYOUT_HWC >()
|
constexpr |
◆ layout_get_rank< TENSOR_LAYOUT_LNHWC >()
|
constexpr |
◆ layout_get_rank< TENSOR_LAYOUT_NHWC >()
|
constexpr |
◆ layout_get_rank< TENSOR_LAYOUT_NMC >()
|
constexpr |
◆ layout_get_rank< TENSOR_LAYOUT_NMD >()
|
constexpr |
◆ SaturateCast()
__device__ __host__ T roccv::detail::SaturateCast | ( | U | v | ) |
Performs a saturation cast from one type to another. Each type must have type traits supported. A saturation cast converts one type to another, clamping values down to the minimum/maximum of the desired cast if the value being cast goes out of bounds. For example, casting a float with a value of 256.0f to a uchar would result in a uchar with value 255.
- Template Parameters
-
T The type to cast <v> to. The number of elements in this type must be <= to that of v.
- Parameters
-
[in] v The value to cast.
- Returns
- The values in v saturate casted to type T.
◆ ScalarRangeCast()
__device__ __host__ T roccv::detail::ScalarRangeCast | ( | U | v | ) |
ScalarRangeCast is for implementation purposes only. Use RangeCast directly instead.
◆ ScalarSaturateCast()
__device__ __host__ T roccv::detail::ScalarSaturateCast | ( | U | v | ) |
ScalarSaturateCast is for implementation purposes only. Use SaturateCast directly.
◆ SetAll()
|
constexpr |
Create a vectorized type with all values set to v.
- Template Parameters
-
T The vectorized type.
- Parameters
-
v The value to set. Value must be the same as the base type of type T.
- Returns
- A vectorized type with all values set to v.
◆ Swizzle()
|
constexpr |
Rearranges the components of a vector according to a given swizzle pattern.
- Template Parameters
-
Pattern The pattern used to rearrange vector components. T The vector type.
- Parameters
-
v The vector to swizzle.
- Returns
v
with its components rearranged according toPattern
.
- Example:
- uchar3 vec = make_uchar3(1, 2, 3);uchar3 vecSwizzled = Swizzle<eSwizzle::ZYXW>(vec);// vecSwizzled = {3, 2, 1}
◆ SwizzleIndicesImpl()
|
constexpr |
Variable Documentation
◆ HasTypeTraits
|
constexpr |
Returns whether the datatype passed in has type traits associated with it.
- Template Parameters
-
T
◆ IsCompound
|
constexpr |
◆ NumComponents
|
constexpr |
Returns the number of components in a given type. Scalar types will have 0 components, while vectorized types will have 1-4 components typically.
- Template Parameters
-
T
◆ NumElements
|
constexpr |
Returns the number of elements in a HIP vectorized type. For example: uchar3 will return 3, int2 will return 2.
- Template Parameters
-
T