常用 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, , beta, Y, );
} 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, , beta, Y, );
}
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, , Y, ); } template <>
void caffe_axpy<double>(const int N, const double alpha, const double* X,
double* Y) { cblas_daxpy(N, alpha, X, , Y, ); }
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);
}
y=x;
template <>
void caffe_copy<float>(const int N, const float* X, float* Y) {
cblas_scopy(N, X, , Y, );
} template <>
void caffe_copy<double>(const int N, const double* X, double* Y) {
cblas_dcopy(N, X, , Y, );
} template <>
void caffe_gpu_copy<float>(const int N, const float* X, float* Y) {
CUBLAS_CHECK(cublasScopy(Caffe::cublas_handle(), N, X, , Y, ));
} template <>
void caffe_gpu_copy<double>(const int N, const double* X, double* Y) {
CUBLAS_CHECK(cublasDcopy(Caffe::cublas_handle(), N, X, , Y, ));
}
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<float>(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, , beta, y, );
}
C(matrix)←αAB + βC
template<typename T>
void gpu_multmat(T* A, T* B, T* C, int M,int K,int N){
const T alpha = ,beta=;
caffe_gpu_gemm(CblasNoTrans,CblasNoTrans,M,N,K,alpha,A,B,beta,C);
}
template<>
void caffe_cpu_gemm<float>(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<typename T>
void cpu_multTmat(T* A, T* B, T* C, int M,int K,int N){
const T alpha = ,beta=;
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<typename T>
void cpu_multmat(T* A, T* B, T* C, int M,int K,int N){
const T alpha = ,beta=;
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);
}
常用 blas 函数的更多相关文章
- oracle(sql)基础篇系列(一)——基础select语句、常用sql函数、组函数、分组函数
花点时间整理下sql基础,温故而知新.文章的demo来自oracle自带的dept,emp,salgrade三张表.解锁scott用户,使用scott用户登录就可以看到自带的表. #使用ora ...
- php常用字符串函数小结
php内置了98个字符串函数(除了基于正则表达式的函数,正则表达式在此不在讨论范围),能够处理字符串中能遇到的每一个方面内容,本文对常用字符串函数进行简单的小结,主要包含以下8部分:1.确定字符串长度 ...
- php常用数组函数回顾一
数组对于程序开发来说是一个必不可少的工具,我根据网上的常用数组函数,结合个人的使用情况,进行数组系列的总结复习.里面当然不只是数组的基本用法,还有相似函数的不同用法的简单实例,力求用最简单的实例,记住 ...
- byte数据的常用操作函数[转发]
/// <summary> /// 本类提供了对byte数据的常用操作函数 /// </summary> public class ByteUtil { ','A','B',' ...
- WordPress主题模板层次和常用模板函数
首页: home.php index.php 文章页: single-{post_type}.php – 如果文章类型是videos(即视频),WordPress就会去查找single-videos. ...
- Python 常用string函数
Python 常用string函数 字符串中字符大小写的变换 1. str.lower() //小写>>> 'SkatE'.lower()'skate' 2. str.upper ...
- MySQL之MySQL常用的函数方法
MySQL常用函数 本篇主要总结了一些在使用MySQL数据库中常用的函数,本篇大部分都是以实例作为讲解,如果有什么建议或者意见欢迎前来打扰. limit Select * from table ord ...
- Delphi常用系统函数总结
Delphi常用系统函数总结 字符串处理函数 Unit System 函数原型 function Concat(s1 [, s2,..., sn]: string): string; 说明 与 S : ...
- iOS开发数据库篇—SQLite常用的函数
iOS开发数据库篇—SQLite常用的函数 一.简单说明 1.打开数据库 int sqlite3_open( const char *filename, // 数据库的文件路径 sqlite3 * ...
随机推荐
- C#-----中使用using详解
1.using指令 using + 命名空间名字 例:using System; using System.Data; 2.using语句 定义一个范围,在范围结束时处理对象,出了这个范 ...
- 7.mongo python 库 pymongo的安装
1.Python 中如果想要和 MongoDB 进行交互就需要借助于 PyMongo 库,在CMD中使用命令即可[注意此处是pip3,pip无法安装]: pip3 install pymongo 2. ...
- 软件工程实践小项目之模拟wc.exe的小程序
github源码和工程文件地址:https://github.com/Jackchenyu/Word_counts/tree/smart 基本要求:要实现wc的基本功能即文件中字符数.单词数.行数的统 ...
- 虚拟机centos7配置本地yum源
在虚拟机中要使用yum命令,就要先配置一下yum源,下面就分享一下这个过程: 1. 挂载iso到vmware,首先得确保CD/DVD连接到镜像.可以这样操作 2. 执行下面的命令 # mkdir /m ...
- GoldenGate 12.3 MA架构介绍系列(5) - 静默安装
软件下载地址 http://www.oracle.com/technetwork/middleware/goldengate/downloads/index.html 下载基于MicroService ...
- BDD数据集(mask_rcnn)1
mask_rcnn中ballon的例子 classsification VS semantic segmention VS object detection VS instance segmentio ...
- ORA-600 [kcblin_3] 解决方法
今日,我们一个sql在某环境执行出错,如下: ORA-00600: 内部错误代码, 参数: [kcblin_3], [103], [253952], [8192], [32769], [312], [ ...
- Pandas截取列的一部分
以股票代码为例: 型式为:6位数字+"."+交易所代码,如600028.SH 如只需保留前6位: pattern = '(\w+)(?:.SZ|.SH)$' df['股票代码'] ...
- vs相同变量高亮显示
https://blog.csdn.net/sinat_33718563/article/details/79241129 在VS2010中调试工程中,常常需要观察相同变量名在不同代码处的位置,VS默 ...
- git将本地项目上传码云
1.首先在码云新建项目. 2.使用git bash工具,进入本地项目所在的文件夹. 3.执行命令 git init,初始化本地git仓库 4.执行命令 git remote add [short-na ...