首页 > 代码库 > 常用 blas 函数
常用 blas 函数
Y=alpha * X +beta*Y
template <>void caffe_cpu_axpby<float>(const int N, const float alpha, const float* X, const float beta, float* Y) { cblas_saxpby(N, alpha, X, 1, beta, Y, 1);}template <>void caffe_cpu_axpby<double>(const int N, const double alpha, const double* X, const double beta, double* Y) { cblas_daxpby(N, alpha, X, 1, beta, Y, 1);}
cblas_dscal(N, beta, Y, incY); Y=Y*beta
cblas_daxpy(N, alpha, X, incX, Y, incY); Y= (alpha * X) + Y)
Y=alpha * X + Y
template <>void caffe_axpy<float>(const int N, const float alpha, const float* X, float* Y) { cblas_saxpy(N, alpha, X, 1, Y, 1); }template <>void caffe_axpy<double>(const int N, const double alpha, const double* X, double* Y) { cblas_daxpy(N, alpha, X, 1, Y, 1); }
DEFINE_VSL_BINARY_FUNC(Add, y[i] = a[i] + b[i]);DEFINE_VSL_BINARY_FUNC(Sub, y[i] = a[i] - b[i]);DEFINE_VSL_BINARY_FUNC(Mul, y[i] = a[i] * b[i]);DEFINE_VSL_BINARY_FUNC(Div, y[i] = a[i] / b[i]);template <>void caffe_add<float>(const int n, const float* a, const float* b,float* y) {vsAdd(n, a, b, y);}template <>void caffe_add<double>(const int n, const double* a, const double* b,double* y) {vdAdd(n, a, b, y);}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。