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); }
常用 blas 函数
时间: 2024-10-13 07:17:04