Add CPU sqrt functions
authorJeff Donahue <jeff.donahue@gmail.com>
Thu, 13 Apr 2017 20:25:16 +0000 (13:25 -0700)
committerJeff Donahue <jeff.donahue@gmail.com>
Thu, 13 Apr 2017 20:29:28 +0000 (13:29 -0700)
include/caffe/util/math_functions.hpp
src/caffe/util/math_functions.cpp

index 60a8404..e549120 100644 (file)
@@ -53,6 +53,9 @@ template <typename Dtype>
 void caffe_sqr(const int N, const Dtype* a, Dtype* y);
 
 template <typename Dtype>
+void caffe_sqrt(const int N, const Dtype* a, Dtype* y);
+
+template <typename Dtype>
 void caffe_add(const int N, const Dtype* a, const Dtype* b, Dtype* y);
 
 template <typename Dtype>
index 71c0227..59625bc 100644 (file)
@@ -197,6 +197,16 @@ void caffe_sqr<double>(const int n, const double* a, double* y) {
 }
 
 template <>
+void caffe_sqrt<float>(const int n, const float* a, float* y) {
+  vsSqrt(n, a, y);
+}
+
+template <>
+void caffe_sqrt<double>(const int n, const double* a, double* y) {
+  vdSqrt(n, a, y);
+}
+
+template <>
 void caffe_exp<float>(const int n, const float* a, float* y) {
   vsExp(n, a, y);
 }