Skip to content

[develop-upstream] Update rocPrim usage for ROCm7 #3003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop-upstream
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion tensorflow/core/kernels/gpu_prim.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ namespace gpuprim = ::hipcub;

// Required for sorting Eigen::half and bfloat16.
namespace rocprim {
#if (TF_ROCM_VERSION >= 50200 && TF_ROCM_VERSION < 70000)
namespace detail {
#if (TF_ROCM_VERSION >= 50200)
template <>
struct float_bit_mask<Eigen::half> {
static constexpr uint16_t sign_bit = 0x8000;
Expand All @@ -99,14 +99,35 @@ struct float_bit_mask<Eigen::bfloat16> {
static constexpr uint16_t mantissa = 0x007F;
using bit_type = uint16_t;
};
}; // namespace detail

#else
namespace traits {
template<>
struct rocprim::traits::define<Eigen::half> {
using float_bit_mask = rocprim::traits::float_bit_mask::values<uint16_t, 0x8000, 0x7C00, 0x03FF>;
using is_arithmetic = rocprim::traits::is_arithmetic::values<true>;
using number_format = rocprim::traits::number_format::values<traits::number_format::kind::floating_point_type>;
};

template<>
struct rocprim::traits::define<tsl::bfloat16> {
using float_bit_mask = rocprim::traits::float_bit_mask::values<uint16_t, 0x8000, 0x7F80, 0x007F>;
using is_arithmetic = rocprim::traits::is_arithmetic::values<true>;
using number_format = rocprim::traits::number_format::values<traits::number_format::kind::floating_point_type>;
};
}; // namespace traits
#endif
#if (TF_ROCM_VERSION < 70000)
namespace detail {
template <>
struct radix_key_codec_base<Eigen::half>
: radix_key_codec_floating<Eigen::half, uint16_t> {};
template <>
struct radix_key_codec_base<tensorflow::bfloat16>
: radix_key_codec_floating<tensorflow::bfloat16, uint16_t> {};
}; // namespace detail
#endif
}; // namespace rocprim

#endif // TENSORFLOW_USE_ROCM
Expand Down