diff options
author | Kai Li <kaili_kloud@163.com> | 2014-02-25 18:41:45 +0800 |
---|---|---|
committer | Kai Li <kaili_kloud@163.com> | 2014-03-23 21:20:50 +0800 |
commit | 910f3128c7947cacfc88ac40828ec7e694cb529a (patch) | |
tree | 05c856849d4d3512296e44c4c8fff8810619d404 /src/caffe/util/math_functions.cpp | |
parent | 699b557c757c4b8cc18a653188913ca78be76149 (diff) | |
download | caffeonacl-910f3128c7947cacfc88ac40828ec7e694cb529a.tar.gz caffeonacl-910f3128c7947cacfc88ac40828ec7e694cb529a.tar.bz2 caffeonacl-910f3128c7947cacfc88ac40828ec7e694cb529a.zip |
Add and test sum of absolute values math functions for CPU and GPU
Diffstat (limited to 'src/caffe/util/math_functions.cpp')
-rw-r--r-- | src/caffe/util/math_functions.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/caffe/util/math_functions.cpp b/src/caffe/util/math_functions.cpp index 29bdaf6c..04a5228e 100644 --- a/src/caffe/util/math_functions.cpp +++ b/src/caffe/util/math_functions.cpp @@ -390,4 +390,24 @@ int caffe_hamming_distance<double>(const int n, const double* x, return dist; } +template <> +float caffe_cpu_asum<float>(const int n, const float* x) { + return cblas_sasum(n, x, 1); +} + +template <> +double caffe_cpu_asum<double>(const int n, const double* x) { + return cblas_dasum(n, x, 1); +} + +template <> +void caffe_gpu_asum<float>(const int n, const float* x, float* y) { + CUBLAS_CHECK(cublasSasum(Caffe::cublas_handle(), n, x, 1, y)); +} + +template <> +void caffe_gpu_asum<double>(const int n, const double* x, double* y) { + CUBLAS_CHECK(cublasDasum(Caffe::cublas_handle(), n, x, 1, y)); +} + } // namespace caffe |