add support for cx_fp16
This commit is contained in:
@@ -484,7 +484,26 @@ class herk
|
||||
{
|
||||
herk<do_trans_A, use_alpha, use_beta>::apply_blas_type(C,A,alpha,beta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<typename TA>
|
||||
arma_inline
|
||||
static
|
||||
void
|
||||
apply
|
||||
(
|
||||
Mat< std::complex<fp16> >& C,
|
||||
const TA& A,
|
||||
const fp16 alpha = fp16(1),
|
||||
const fp16 beta = fp16(0)
|
||||
)
|
||||
{
|
||||
herk_emul<do_trans_A, use_alpha, use_beta>::apply(C,A,alpha,beta);
|
||||
}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ class op_dot
|
||||
template<typename eT>
|
||||
arma_hot inline static typename arma_blas_real_only<eT>::result
|
||||
direct_dot(const uword n_elem, const eT* const A, const eT* const B);
|
||||
|
||||
|
||||
template<typename eT>
|
||||
arma_hot inline static typename arma_fp16_only<eT>::result
|
||||
arma_hot inline static typename arma_blas_cx_only<eT>::result
|
||||
direct_dot(const uword n_elem, const eT* const A, const eT* const B);
|
||||
|
||||
|
||||
template<typename eT>
|
||||
arma_hot inline static typename arma_cx_only<eT>::result
|
||||
arma_hot inline static typename arma_fp16_real_or_cx_only<eT>::result
|
||||
direct_dot(const uword n_elem, const eT* const A, const eT* const B);
|
||||
|
||||
template<typename eT>
|
||||
@@ -98,7 +98,7 @@ class op_cdot
|
||||
arma_hot inline static eT direct_cdot(const uword n_elem, const eT* const A, const eT* const B, const typename arma_blas_real_or_cx_only<eT>::result* junk = 0);
|
||||
|
||||
template<typename eT>
|
||||
arma_hot inline static eT direct_cdot(const uword n_elem, const eT* const A, const eT* const B, const typename arma_fp16_only<eT>::result* junk = 0);
|
||||
arma_hot inline static eT direct_cdot(const uword n_elem, const eT* const A, const eT* const B, const typename arma_fp16_real_or_cx_only<eT>::result* junk = 0);
|
||||
|
||||
template<typename T1, typename T2>
|
||||
arma_hot inline static typename T1::elem_type apply (const T1& X, const T2& Y);
|
||||
|
||||
@@ -98,7 +98,7 @@ op_dot::direct_dot_arma(const uword n_elem, const eT* const A, const eT* const B
|
||||
|
||||
|
||||
|
||||
//! for two arrays, floating-point version
|
||||
//! for two arrays, float and double version
|
||||
template<typename eT>
|
||||
inline
|
||||
typename arma_blas_real_only<eT>::result
|
||||
@@ -129,23 +129,10 @@ op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B)
|
||||
|
||||
|
||||
|
||||
//! for two arrays, fp16 version
|
||||
template<typename eT>
|
||||
inline
|
||||
typename arma_fp16_only<eT>::result
|
||||
op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
return op_dot::direct_dot_arma(n_elem, A, B);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! for two arrays, complex version
|
||||
template<typename eT>
|
||||
inline
|
||||
typename arma_cx_only<eT>::result
|
||||
typename arma_blas_cx_only<eT>::result
|
||||
op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B)
|
||||
{
|
||||
if(n_elem <= 16u) { return op_dot::direct_dot_arma(n_elem, A, B); }
|
||||
@@ -171,6 +158,17 @@ op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B)
|
||||
|
||||
|
||||
|
||||
//! for two arrays, fp16 version
|
||||
template<typename eT>
|
||||
inline
|
||||
typename arma_fp16_real_or_cx_only<eT>::result
|
||||
op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B)
|
||||
{
|
||||
return op_dot::direct_dot_arma(n_elem, A, B);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! for two arrays, integral version
|
||||
template<typename eT>
|
||||
inline
|
||||
@@ -502,7 +500,7 @@ op_cdot::direct_cdot(const uword n_elem, const eT* const A, const eT* const B, c
|
||||
template<typename eT>
|
||||
inline
|
||||
eT
|
||||
op_cdot::direct_cdot(const uword n_elem, const eT* const A, const eT* const B, const typename arma_fp16_only<eT>::result* junk)
|
||||
op_cdot::direct_cdot(const uword n_elem, const eT* const A, const eT* const B, const typename arma_fp16_real_or_cx_only<eT>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
@@ -49,7 +49,7 @@ class op_norm
|
||||
|
||||
template<typename eT> inline static typename get_pod_type<eT>::result mat_norm_1(const Mat<eT>& X);
|
||||
template<typename eT> inline static typename get_pod_type<eT>::result mat_norm_2(const Mat<eT>& X, const typename arma_blas_real_or_cx_only<eT>::result* junk = nullptr);
|
||||
template<typename eT> inline static typename get_pod_type<eT>::result mat_norm_2(const Mat<eT>& X, const typename arma_fp16_only<eT>::result* junk = nullptr);
|
||||
template<typename eT> inline static typename get_pod_type<eT>::result mat_norm_2(const Mat<eT>& X, const typename arma_fp16_real_or_cx_only<eT>::result* junk = nullptr);
|
||||
|
||||
template<typename eT> inline static typename get_pod_type<eT>::result mat_norm_inf(const Mat<eT>& X);
|
||||
};
|
||||
|
||||
@@ -954,7 +954,7 @@ op_norm::mat_norm_2(const Mat<eT>& X, const typename arma_blas_real_or_cx_only<e
|
||||
template<typename eT>
|
||||
inline
|
||||
typename get_pod_type<eT>::result
|
||||
op_norm::mat_norm_2(const Mat<eT>& X, const typename arma_fp16_only<eT>::result* junk)
|
||||
op_norm::mat_norm_2(const Mat<eT>& X, const typename arma_fp16_real_or_cx_only<eT>::result* junk)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
arma_ignore(junk);
|
||||
|
||||
@@ -40,11 +40,12 @@ template<> struct arma_scalar_only< ulng_t > { typedef ulng_t result; };
|
||||
template<> struct arma_scalar_only< slng_t > { typedef slng_t result; };
|
||||
template<> struct arma_scalar_only< float > { typedef float result; };
|
||||
template<> struct arma_scalar_only< double > { typedef double result; };
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_scalar_only< fp16 > { typedef fp16 result; };
|
||||
#endif
|
||||
template<> struct arma_scalar_only< cx_float > { typedef cx_float result; };
|
||||
template<> struct arma_scalar_only< cx_double > { typedef cx_double result; };
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_scalar_only< fp16 > { typedef fp16 result; };
|
||||
template<> struct arma_scalar_only< cx_fp16 > { typedef cx_fp16 result; };
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -92,11 +93,12 @@ template<> struct arma_signed_only< s64 > { typedef s64 result; };
|
||||
template<> struct arma_signed_only< slng_t > { typedef slng_t result; };
|
||||
template<> struct arma_signed_only< float > { typedef float result; };
|
||||
template<> struct arma_signed_only< double > { typedef double result; };
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_signed_only< fp16 > { typedef fp16 result; };
|
||||
#endif
|
||||
template<> struct arma_signed_only< cx_float > { typedef cx_float result; };
|
||||
template<> struct arma_signed_only< cx_double > { typedef cx_double result; };
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_signed_only< fp16 > { typedef fp16 result; };
|
||||
template<> struct arma_signed_only< cx_fp16 > { typedef cx_fp16 result; };
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -129,11 +131,12 @@ template<typename T> struct arma_real_or_cx_only { };
|
||||
|
||||
template<> struct arma_real_or_cx_only< float > { typedef float result; };
|
||||
template<> struct arma_real_or_cx_only< double > { typedef double result; };
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_real_or_cx_only< fp16 > { typedef fp16 result; };
|
||||
#endif
|
||||
template<> struct arma_real_or_cx_only< cx_float > { typedef cx_float result; };
|
||||
template<> struct arma_real_or_cx_only< cx_double > { typedef cx_double result; };
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_real_or_cx_only< fp16 > { typedef fp16 result; };
|
||||
template<> struct arma_real_or_cx_only< cx_fp16 > { typedef cx_fp16 result; };
|
||||
#endif
|
||||
|
||||
|
||||
template<typename T> struct arma_blas_real_or_cx_only { };
|
||||
@@ -145,10 +148,37 @@ template<> struct arma_blas_real_or_cx_only< cx_double > { typedef cx_double res
|
||||
|
||||
|
||||
|
||||
template<typename T> struct arma_fp16_real_or_cx_only { };
|
||||
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_fp16_real_or_cx_only< fp16 > { typedef fp16 result; };
|
||||
template<> struct arma_fp16_real_or_cx_only< cx_fp16 > { typedef cx_fp16 result; };
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
template<typename T> struct arma_cx_only { };
|
||||
|
||||
template<> struct arma_cx_only< cx_float > { typedef cx_float result; };
|
||||
template<> struct arma_cx_only< cx_double > { typedef cx_double result; };
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_cx_only< cx_fp16 > { typedef cx_fp16 result; };
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
template<typename T> struct arma_blas_cx_only { };
|
||||
|
||||
template<> struct arma_blas_real_only< cx_float > { typedef cx_float result; };
|
||||
template<> struct arma_blas_real_only< cx_double > { typedef cx_double result; };
|
||||
|
||||
|
||||
|
||||
template<typename T> struct arma_cx_fp16_only { };
|
||||
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct arma_cx_fp16_only< cx_fp16 > { typedef cx_fp16 result; };
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1119,6 +1119,26 @@ struct is_cx_double< std::complex<double> >
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
struct is_cx_fp16
|
||||
{
|
||||
static constexpr bool value = false;
|
||||
static constexpr bool yes = false;
|
||||
static constexpr bool no = true;
|
||||
};
|
||||
|
||||
#ifdef ARMA_HAVE_FP16
|
||||
template<>
|
||||
struct is_cx_fp16< std::complex<fp16> >
|
||||
{
|
||||
static constexpr bool value = true;
|
||||
static constexpr bool yes = true;
|
||||
static constexpr bool no = false;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
struct is_supported_elem_type
|
||||
{
|
||||
@@ -1137,7 +1157,8 @@ struct is_supported_elem_type
|
||||
is_double<T1>::value ||
|
||||
is_fp16<T1>::value ||
|
||||
is_cx_float<T1>::value ||
|
||||
is_cx_double<T1>::value;
|
||||
is_cx_double<T1>::value ||
|
||||
is_cx_fp16<T1>::value;
|
||||
};
|
||||
|
||||
|
||||
@@ -1194,6 +1215,7 @@ template<> struct is_non_integral< std::complex<double> > { static constexpr boo
|
||||
|
||||
#if defined(ARMA_HAVE_FP16)
|
||||
template<> struct is_non_integral< fp16 > { static constexpr bool value = true; };
|
||||
template<> struct is_non_integral< std::complex<fp16> > { static constexpr bool value = true; };
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -154,7 +154,8 @@ typedef void* void_ptr;
|
||||
|
||||
#if defined(ARMA_FORCE_USE_FP16) || defined(ARMA_GOOD_FP16)
|
||||
#define ARMA_HAVE_FP16
|
||||
typedef std::float16_t fp16;
|
||||
typedef std::float16_t fp16;
|
||||
typedef std::complex<std::float16_t> cx_fp16;
|
||||
#endif
|
||||
|
||||
#if defined(ARMA_FORCE_USE_FP16) && !defined(ARMA_GOOD_FP16)
|
||||
|
||||
@@ -104,6 +104,12 @@ typedef Col <fp16> fp16_vec;
|
||||
typedef Col <fp16> fp16_colvec;
|
||||
typedef Row <fp16> fp16_rowvec;
|
||||
typedef Cube<fp16> fp16_cube;
|
||||
|
||||
typedef Mat <cx_fp16> cx_fp16_mat;
|
||||
typedef Col <cx_fp16> cx_fp16_vec;
|
||||
typedef Col <cx_fp16> cx_fp16_colvec;
|
||||
typedef Row <cx_fp16> cx_fp16_rowvec;
|
||||
typedef Cube<cx_fp16> cx_fp16_cube;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -153,6 +159,11 @@ typedef SpMat <fp16> sp_fp16_mat;
|
||||
typedef SpCol <fp16> sp_fp16_vec;
|
||||
typedef SpCol <fp16> sp_fp16_colvec;
|
||||
typedef SpRow <fp16> sp_fp16_rowvec;
|
||||
|
||||
typedef SpMat <cx_fp16> sp_cx_fp16_mat;
|
||||
typedef SpCol <cx_fp16> sp_cx_fp16_vec;
|
||||
typedef SpCol <cx_fp16> sp_cx_fp16_colvec;
|
||||
typedef SpRow <cx_fp16> sp_cx_fp16_rowvec;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user