void log10 ( tensor& dest, const tensor& src ) { DLIB_CASSERT(dest.size() == src.size()); #ifdef DLIB_USE_CUDA cuda::log10(dest,src); #else dest = log10(mat(src)); #endif }
void curand_generator:: fill_gaussian ( tensor& data, float mean, float stddev ) { if (data.size() == 0) return; CHECK_CURAND(curandGenerateNormal((curandGenerator_t)handle, data.device(), data.size(), mean, stddev)); }
void curand_generator:: fill_uniform ( tensor& data ) { if (data.size() == 0) return; CHECK_CURAND(curandGenerateUniform((curandGenerator_t)handle, data.device(), data.size())); }
void scale_rows ( tensor& out, const tensor& m, const tensor& v ) { DLIB_CASSERT(have_same_dimensions(out,m)); DLIB_CASSERT(is_vector(v)); if (m.size() == 0 && v.size() == 0) return; DLIB_CASSERT(m.size() != 0); DLIB_CASSERT(m.num_samples() == v.size()); #ifdef DLIB_USE_CUDA cuda::scale_rows(out, m, v); #else out = scale_rows(mat(m), mat(v)); #endif }
void scale_columns ( tensor& out, const tensor& m, const tensor& v ) { DLIB_CASSERT(have_same_dimensions(out,m)); DLIB_CASSERT(is_vector(v)); if (m.size() == 0 && v.size() == 0) return; DLIB_CASSERT(m.size() != 0); DLIB_CASSERT(m.size()/m.num_samples() == v.size()); #ifdef DLIB_USE_CUDA cuda::scale_columns(out, m, v); #else DLIB_CASSERT(false, "shouldn't be called right now"); out = scale_columns(mat(m), mat(v)); #endif }
void scale_rows2 ( float beta, tensor& out, const tensor& m1, const tensor& m2, const tensor& v1, const tensor& v2 ) { DLIB_CASSERT(have_same_dimensions(out,m1)); DLIB_CASSERT(have_same_dimensions(out,m2)); DLIB_CASSERT(have_same_dimensions(v1,v2)); DLIB_CASSERT(is_vector(mat(v1))); DLIB_CASSERT(v1.size() == m1.num_samples()); #ifdef DLIB_USE_CUDA cuda::scale_rows2(beta, out, m1, m2, v1, v2); #else if (beta == 0) out = scale_rows(mat(m1) - scale_rows(mat(m2),mat(v1)), mat(v2)); else out = beta*mat(out) + scale_rows(mat(m1) - scale_rows(mat(m2),mat(v1)), mat(v2)); #endif }
tensor<T, M> add_apply(tensor<T, M>& a, tensor<T, M>& b) { tensor<T, M> result(extents[a.size()]); apply_binary_functor(result, a, b, BF_ADD); return result; }
tensor<T, M> add_for(tensor<T, M>& a, tensor<T, M>& b) { tensor<T, M> result(extents[a.size()]); for (unsigned int i=0; i<a.size(); i++) result[i] = a[i] + b[i]; return result; }