31 #ifndef __TENSOR_OPS_HPP__
32 #define __TENSOR_OPS_HPP__
68 template<
class __value_type,
class __memory_space_type>
75 template<
class __value_type,
class __memory_space_type>
89 template<
class V1,
class M>
96 template<
class V1,
class M>
108 template<
class __value_type,
class __memory_space_type,
class __memory_layout_type>
119 template<
class __value_type,
class __memory_space_type,
class __memory_layout_type,
class S>
259 template<
class V1,
class V2,
class M,
class S1,
class S2>
260 void apply_scalar_functor(tensor<V1, M>&dst,
const tensor<V2, M>&src,
const ScalarFunctor& sf,
const int& numparams=0,
const tensor<unsigned char,M>* mask=NULL,
const S1& p=S1(),
const S2& p2=S2());
265 template<
class V1,
class V2,
class M,
class S1,
class S2>
266 void apply_scalar_functor(tensor<V1, M, column_major>& dst,
const tensor<V2, M, column_major>& src,
const ScalarFunctor& sf,
const int& numparams=0,
const tensor<unsigned char,M,column_major>* mask=NULL,
const S1& p=S1(),
const S2& p2=S2()){
267 apply_scalar_functor(*
reinterpret_cast<tensor<V1, M, row_major>*
>(&dst), *
reinterpret_cast<const tensor<V2, M, row_major>*
>(&src), sf, numparams,
reinterpret_cast<const tensor<unsigned char, M, row_major>*
>(mask), p, p2);
291 typedef typename D::value_type V;
306 template<
class D,
class S>
309 typedef typename S::value_type V;
334 typedef typename D::value_type V;
355 template<
class D,
class S>
358 typedef typename S::value_type V;
405 template<
class D,
class S>
476 BF_LOGCE_OF_LOGISTIC,
484 BF_EPSILON_INSENSITIVE_LOSS,
485 BF_DEPSILON_INSENSITIVE_LOSS,
506 template<
class V1,
class V2,
class V3,
class M,
class S1,
class S2>
507 void apply_binary_functor(tensor<V1, M>& dst,
const tensor<V2, M>& src1,
const tensor<V3, M>&src2,
const BinaryFunctor& bf,
const int& numparams=0,
const S1& p=S1(),
const S2& p2=S2());
508 template<
class V1,
class V2,
class V3,
class M,
class S1,
class S2>
509 void apply_binary_functor(tensor<V1, M, column_major>& dst,
const tensor<V2, M, column_major>& src1,
const tensor<V3, M, column_major>& src2,
const BinaryFunctor& bf,
const int& numparams=0,
const S1& p=S1(),
const S2& p2=S2()){
510 apply_binary_functor(*
reinterpret_cast<tensor<V1, M, row_major>*
>(&dst), *
reinterpret_cast<const tensor<V2, M, row_major>*
>(&src1), *
reinterpret_cast<const tensor<V3, M, row_major>*
>(&src2), bf, numparams, p, p2);
528 template<
class D,
class S>
531 typedef typename S::value_type V;
551 template<
class D,
class S,
class S2>
554 typedef typename S::value_type V;
575 template<
class D,
class S>
578 typedef typename S::value_type V;
600 template<
class D,
class S,
class S2>
624 template<
class D,
class S>
649 template<
class D,
class S,
class S2>
662 template<
class __value_type,
class __memory_space_type,
class __memory_layout_type>
681 template<
class __value_type,
class __memory_space_type>
bool has_inf(
const tensor<__value_type, __memory_space_type>& v);
693 template<
class __value_type,
class __memory_space_type>
bool has_nan(
const tensor<__value_type, __memory_space_type>& v);
706 template<
class __value_type,
class __memory_space_type>
unsigned int count(
const tensor<__value_type, __memory_space_type>& v,
const __value_type& s);
718 template<
class __value_type,
class __memory_space_type>
float sum(
const tensor<__value_type, __memory_space_type>& v);
730 template<
class __value_type,
class __memory_space_type>
float norm2(
const tensor<__value_type, __memory_space_type>& v);
743 template<
class __value_type,
class __memory_space_type>
float diff_norm2(
const tensor<__value_type, __memory_space_type>& v,
const tensor<__value_type, __memory_space_type>& w);
755 template<
class __value_type,
class __memory_space_type>
float norm1(
const tensor<__value_type, __memory_space_type>& v);
767 template<
class __value_type,
class __memory_space_type>
float minimum(
const tensor<__value_type, __memory_space_type>& v);
779 template<
class __value_type,
class __memory_space_type>
float maximum(
const tensor<__value_type, __memory_space_type>& v);
791 template<
class __value_type,
class __memory_space_type>
float mean(
const tensor<__value_type, __memory_space_type>& v);
803 template<
class __value_type,
class __memory_space_type>
float var(
const tensor<__value_type, __memory_space_type>& v);
816 template<
class __value_type,
class __memory_space_type>
817 typename tensor<__value_type, __memory_space_type>::index_type
818 arg_max(
const tensor<__value_type, __memory_space_type>& v);
820 template<
class __value_type,
class __memory_space_type>
821 typename tensor<__value_type, __memory_space_type, column_major>::index_type
832 template<
class __value_type,
class __memory_space_type>
833 typename tensor<__value_type, __memory_space_type>::index_type
834 arg_min(
const tensor<__value_type, __memory_space_type>& v);
836 template<
class __value_type,
class __memory_space_type>
837 typename tensor<__value_type, __memory_space_type, column_major>::index_type
857 template<
class T,
class V,
class M>
864 template<
class T,
class V,
class M>
871 template<
class T,
class V,
class M>
878 template<
class T,
class V,
class M>
889 template<
class T,
class V,
class M>
896 template<
class T,
class V,
class M>
903 template<
class T,
class V,
class M>
910 template<
class T,
class V,
class M>
922 template<
class T,
class V,
class M>
930 template<
class T,
class V,
class M>
937 template<
class T,
class V,
class M>
944 template<
class T,
class V,
class M>
955 template<
class T,
class V,
class M>
962 template<
class T,
class V,
class M>
964 operator<=(const cuv::tensor<T, V, M>& v,
const T cmp){
969 template<
class T,
class V,
class M>
976 template<
class T,
class V,
class M>
978 operator<(const cuv::tensor<T, V, M>& v,
const T cmp){
983 template<
class T,
class V,
class M>
990 template<
class T,
class V,
class M>
997 template<
class T,
class V,
class M>
1004 template<
class T,
class V,
class M>
1016 template<
class T,
class V,
class M>
1023 template<
class T,
class V,
class M>
1029 template<
class T,
class V,
class M>
1035 template<
class T,
class V,
class M>
1042 template<
class T,
class V,
class M>
1048 template<
class T,
class V,
class M>
1059 template<
class T,
class V,
class M>
1065 template<
class T,
class V,
class M>
1072 template<
class T,
class V,
class M>
1078 template<
class T,
class V,
class M>
1088 template<
class T,
class V,
class M>
1095 template<
class V,
class M>
1099 temp = (
unsigned char) 1;