place-holder implementation of specialised accu() for fp16
This commit is contained in:
@@ -31,7 +31,9 @@ accu(const T1& expr, const typename enable_if< is_arma_type<T1>::value >::result
|
||||
|
||||
arma_ignore(junk);
|
||||
|
||||
return op_accu_mat::apply(expr);
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
return (is_fp16<eT>::yes || is_cx_fp16<eT>::yes) ? op_accu_fp16mat::apply(expr) : op_accu_mat::apply(expr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,15 @@ struct op_accu_mat
|
||||
|
||||
|
||||
|
||||
struct op_accu_fp16mat
|
||||
: public traits_op_passthru
|
||||
{
|
||||
template<typename T1>
|
||||
static inline typename T1::elem_type apply(const T1& X);
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct op_accu_cube
|
||||
: public traits_op_passthru
|
||||
{
|
||||
|
||||
@@ -654,6 +654,37 @@ op_accu_mat::apply(const subview_col<eT>& X)
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
typename T1::elem_type
|
||||
op_accu_fp16mat::apply(const T1& X)
|
||||
{
|
||||
arma_debug_sigprint();
|
||||
|
||||
// TODO: this is a rudimentary place-holder implementation
|
||||
|
||||
typedef typename T1::elem_type eT;
|
||||
|
||||
typedef typename conditional_promote_type<is_real_or_cx<eT>::value, eT, float>::result acc_eT;
|
||||
|
||||
const quasi_unwrap<T1> U(X);
|
||||
|
||||
const uword N = U.M.n_elem;
|
||||
const eT* mem = U.M.memptr();
|
||||
|
||||
acc_eT acc = acc_eT(0);
|
||||
|
||||
for(uword i=0; i<N; ++i) { acc += acc_eT( mem[i] ); }
|
||||
|
||||
return eT(acc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
template<typename T1>
|
||||
inline
|
||||
typename T1::elem_type
|
||||
|
||||
Reference in New Issue
Block a user