真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

常用blas函數(shù)-創(chuàng)新互聯(lián)

Y=alpha * X +beta*Y 常用blas函數(shù)
template <>
void caffe_cpu_axpby(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(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)

創(chuàng)新互聯(lián)專(zhuān)注于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站制作、網(wǎng)站開(kāi)發(fā)。公司秉持“客戶(hù)至上,用心服務(wù)”的宗旨,從客戶(hù)的利益和觀(guān)點(diǎn)出發(fā),讓客戶(hù)在網(wǎng)絡(luò)營(yíng)銷(xiāo)中找到自己的駐足之地。尊重和關(guān)懷每一位客戶(hù),用嚴(yán)謹(jǐn)?shù)膽B(tài)度對(duì)待客戶(hù),用專(zhuān)業(yè)的服務(wù)創(chuàng)造價(jià)值,成為客戶(hù)值得信賴(lài)的朋友,為客戶(hù)解除后顧之憂(yōu)。

Y=alpha * X + Y

template <>
void caffe_axpy(const int N, const float alpha, const float* X,
float* Y) { cblas_saxpy(N, alpha, X, 1, Y, 1); }

template<>
void caffe_axpy(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(const int n, const float* a, const float* b,
float* y) {
vsAdd(n, a, b, y);
}

template<>
void caffe_add(const int n, const double* a, const double* b,
double* y) {
vdAdd(n, a, b, y);
}

y=x;

template <>
void caffe_copy(const int N, const float* X, float* Y) {
  cblas_scopy(N, X,1, Y, 1);
}

template<>
void caffe_copy(const int N, const double* X, double* Y) {
  cblas_dcopy(N, X,1, Y, 1);
}

template<>
void caffe_gpu_copy(const int N, const float* X, float* Y) {
  CUBLAS_CHECK(cublasScopy(Caffe::cublas_handle(), N, X,1, Y, 1));
}

template<>
void caffe_gpu_copy(const int N, const double* X, double* Y) {
  CUBLAS_CHECK(cublasDcopy(Caffe::cublas_handle(), N, X,1, Y, 1));
}

Computes alpha*x*y' + A.

cblas_sger
Multiplies vector X by the transform of vector Y, then adds matrix A (single precison).

Multiplies vector X by the transform of vector Y, then adds matrix A (single precison).
void cblas_sger (
const enum CBLAS_ORDER Order,
const int M,
const int N,
const float alpha,
const float *X,
const int incX,
const float *Y,
const int incY,
float *A,
const int lda
);

Y(vetor)←αAX + βY

This function multiplies A * X (after transposing A, if needed) and multiplies the resulting matrix by alpha.
It then multiplies vector Y by beta. It stores the sum of these two products in vector Y.

template <>
void caffe_cpu_gemv(const CBLAS_TRANSPOSE TransA, const int M,
const int N, const float alpha, const float* A, const float* x,
const float beta, float* y) {
  cblas_sgemv(CblasRowMajor, TransA, M, N, alpha, A, N, x,1, beta, y, 1);
}

C(matrix)←αAB + βC

template
void gpu_multmat(T* A, T* B, T* C, int M,int K,int N){
const T alpha = 1,beta=0;
     caffe_gpu_gemm(CblasNoTrans,CblasNoTrans,M,N,K,alpha,A,B,beta,C);
}
template<>
void caffe_cpu_gemm(const CBLAS_TRANSPOSE TransA,
const CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
const float alpha, const float* A, const float* B, const float beta,
float* C) {
int lda = (TransA == CblasNoTrans) ? K : M;
int ldb = (TransB == CblasNoTrans) ? N : K;
  cblas_sgemm(CblasRowMajor, TransA, TransB, M, N, K, alpha, A, lda, B,
      ldb, beta, C, N);
}
A=M*N  B=M*K
C=A'*B N M K

template void cpu_multTmat(T* A, T* B, T* C, int M,int K,int N){ const T alpha = 1,beta=0; caffe_cpu_gemm(CblasTrans,CblasNoTrans,M,N,K,alpha,A,B,beta,C); // cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, alpha, A, M, B, K, beta, C, M);}
A=M*N B=N*K
C=A*B   M N K

template void cpu_multmat(T* A, T* B, T* C, int M,int K,int N){ const T alpha = 1,beta=0; caffe_cpu_gemm(CblasNoTrans,CblasNoTrans,M,N,K,alpha,A,B,beta,C); // cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, alpha, A, M, B, K, beta, C, M);}

分享標(biāo)題:常用blas函數(shù)-創(chuàng)新互聯(lián)
分享地址:http://weahome.cn/article/djhscj.html

其他資訊

在線(xiàn)咨詢(xún)

微信咨詢(xún)

電話(huà)咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部