caffe: math_functions

本文详细介绍了 Caffe 框架中基于 CPU 的两种核心数学运算:gemv 和 gemm。gemv 主要用于实现向量与矩阵的乘法运算,而 gemm 则针对矩阵间的乘法运算进行了优化。这两种操作都支持转置功能,并能够灵活地调整输入输出矩阵的维度。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、

/*  A:m*n
 *  if CblasTrans
 *      B:m*1
 *      C:n*1
 *      C=alpha*A'*B+beta*C
 *  else
 *      B:n*1
 *      C:m*1
 *      C=alpha*A*B+beta*C
 *  end
 */ 
caffe_cpu_gemv<Dtype>(CblasTrans/CblasNoTrans,
        m, n, alpha, A, B, beta, C);

2、

/*  C:m*n
 *  op(A):m*k
 *  op(B):k*n
 *  C=alpha*op( A )*op( B ) + beta*C
 *  function X=op(X)
 *      if CblasTrans
 *          X=X'
 *      else
 *          X=X
 *      end
 */
caffe_cpu_gemm<Dtype>(CblasTrans/CblasNoTrans,
        CblasTrans/CblasNoTrans,
        m, n, k, alpha, A, B, beta, C);
-- Build files have been written to: /root/Workspace/openpose/build/caffe/src/openpose_lib-build [ 75%] Performing build step for 'openpose_lib' [ 1%] Running C++/Python protocol buffer compiler on /root/Workspace/openpose/3rdparty/caffe/src/caffe/proto/caffe.proto [ 1%] Building CXX object src/caffe/CMakeFiles/caffeproto.dir/__/__/include/caffe/proto/caffe.pb.cc.o [ 1%] Linking CXX static library ../../lib/libcaffeproto.a [ 1%] Built target caffeproto [ 1%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/util/cuda_compile_1_generated_math_functions.cu.o [ 1%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/layers/cuda_compile_1_generated_absval_layer.cu.o [ 2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/layers/cuda_compile_1_generated_base_data_layer.cu.o [ 2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/layers/cuda_compile_1_generated_accuracy_layer.cu.o [ 2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/layers/cuda_compile_1_generated_batch_norm_layer.cu.o [ 2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/layers/cuda_compile_1_generated_batch_reindex_layer.cu.o [ 4%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/layers/cuda_compile_1_generated_bnll_layer.cu.o [ 4%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile_1.dir/layers/cuda_compile_1_generated_bias_layer.cu.o In file included from /root/Workspace/openpose/3rdparty/caffe/src/caffe/util/math_functions.cu:1: /usr/local/cuda-11.8/include/math_functions.h:54:2: warning: #warning "math_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release. Please use cuda_runtime_api.h or cuda_runtime.h instead." [-Wcpp] 54 | #warning "math_functions.h is an internal header file and must not be used directly. This file will be removed in a future CUDA release.
03-15
In file included from /usr/include/boost/math/special_functions/detail/round_fwd.hpp:11, from /usr/include/boost/math/special_functions/math_fwd.hpp:29, from /usr/include/boost/math/special_functions/next.hpp:13, from /root/Workspace/openpose/3rdparty/caffe/src/caffe/util/math_functions.cpp:1: /usr/include/boost/math/tools/config.hpp:23:6: warning: #warning "The minimum language standard to use Boost.Math will be C++14 starting in July 2023 (Boost 1.82 release)" [-Wcpp] 23 | # warning "The minimum language standard to use Boost.Math will be C++14 starting in July 2023 (Boost 1.82 release)" | ^~~~~~~ In file included from /usr/include/boost/bind/detail/requires_cxx11.hpp:9, from /usr/include/boost/bind/bind.hpp:24, from /usr/include/boost/bind.hpp:29, from /root/Workspace/openpose/3rdparty/caffe/src/caffe/util/signal_handler.cpp:1: /usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’ 36 | BOOST_PRAGMA_MESSAGE( | ^~~~~~~~~~~~~~~~~~~~ /root/Workspace/openpose/3rdparty/caffe/src/caffe/util/io.cpp: In function ‘bool caffe::ReadProtoFromBinaryFile(const char*, google::protobuf::Message*)’: /root/Workspace/openpose/3rdparty/caffe/src/caffe/util/io.cpp:57:66: error: no matching function for call to ‘google::protobuf::io::CodedInputStream::SetTotalBytesLimit(const int&, int)’ 57 | coded_input->SetTotalBytesLimit(kProtoReadBytesLimit, 536870912); | ^ In file included from /root/Workspace/openpose/3rdparty/caffe/src/caffe/util/io.cpp:2: /usr/local/include/google/protobuf/io/coded_stream.h:407:8: note: candidate: ‘void google::pr
03-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值