SWDEV-293749 - Fix for operator mixup

Change-Id: I61d1fea5a6ed2176dd92050c6d96cee1af3a39fb


[ROCm/clr commit: d0920c5959]
This commit is contained in:
Sarbojit Sarkar
2022-07-26 09:41:49 +00:00
committed by Maneesh Gupta
parent d650f7a50c
commit cd6c8fc2fb
2 changed files with 24 additions and 24 deletions
@@ -106,15 +106,20 @@ THE SOFTWARE.
return lhs; \
}
#define COMPLEX_MUL_PREOP_OVERLOAD(type) \
__HOST_DEVICE__ static inline type& operator*=(type& lhs, const type& rhs) { \
lhs = lhs * rhs; \
return lhs; \
#define COMPLEX_MUL_PREOP_OVERLOAD(type) \
__HOST_DEVICE__ static inline type& operator*=(type& lhs, const type& rhs) { \
type temp{lhs}; \
lhs.x = rhs.x * temp.x - rhs.y * temp.y; \
lhs.y = rhs.y * temp.x + rhs.x * temp.y; \
return lhs; \
}
#define COMPLEX_DIV_PREOP_OVERLOAD(type) \
__HOST_DEVICE__ static inline type& operator/=(type& lhs, const type& rhs) { \
lhs = lhs / rhs; \
__HOST_DEVICE__ static inline type& operator/=(type& lhs, const type& rhs) { \
type temp; \
temp.x = (lhs.x*rhs.x + lhs.y * rhs.y) / (rhs.x*rhs.x + rhs.y*rhs.y); \
temp.y = (lhs.y * rhs.x - lhs.x * rhs.y) / (rhs.x*rhs.x + rhs.y*rhs.y); \
lhs = temp; \
return lhs; \
}
@@ -544,6 +544,13 @@ template <typename __T> struct is_scalar : public integral_constant<bool, __is_s
data *= x.data;
return *this;
}
friend __HOST_DEVICE__ inline constexpr HIP_vector_type operator*(
HIP_vector_type x, const HIP_vector_type& y) noexcept
{
return HIP_vector_type{ x } *= y;
}
template<
typename U,
typename std::enable_if<
@@ -554,6 +561,12 @@ template <typename __T> struct is_scalar : public integral_constant<bool, __is_s
return *this *= HIP_vector_type{x};
}
friend __HOST_DEVICE__ inline constexpr HIP_vector_type operator/(
HIP_vector_type x, const HIP_vector_type& y) noexcept
{
return HIP_vector_type{ x } /= y;
}
__HOST_DEVICE__
HIP_vector_type& operator/=(const HIP_vector_type& x) noexcept
{
@@ -709,15 +722,6 @@ template <typename __T> struct is_scalar : public integral_constant<bool, __is_s
return HIP_vector_type<T, n>{x} -= y;
}
template<typename T, unsigned int n>
__HOST_DEVICE__
inline
constexpr
HIP_vector_type<T, n> operator*(
const HIP_vector_type<T, n>& x, const HIP_vector_type<T, n>& y) noexcept
{
return HIP_vector_type<T, n>{x} *= y;
}
template<typename T, unsigned int n, typename U>
__HOST_DEVICE__
inline
@@ -737,15 +741,6 @@ template <typename __T> struct is_scalar : public integral_constant<bool, __is_s
return HIP_vector_type<T, n>{x} *= y;
}
template<typename T, unsigned int n>
__HOST_DEVICE__
inline
constexpr
HIP_vector_type<T, n> operator/(
const HIP_vector_type<T, n>& x, const HIP_vector_type<T, n>& y) noexcept
{
return HIP_vector_type<T, n>{x} /= y;
}
template<typename T, unsigned int n, typename U>
__HOST_DEVICE__
inline