#ifndef CAFFE2_UTILS_MATH_DETAIL_H_ #define CAFFE2_UTILS_MATH_DETAIL_H_ namespace caffe2 { class CPUContext; namespace math { namespace detail { // proxy to a class because of partial specialization limitations for functions template struct ScaleImpl { inline void operator()( const int N, const float alpha, const T* x, T* y, Context* context) { Scale(N, alpha, x, y, context); } }; // Put light-weight implementations in .h file to enable inlining template struct ScaleImpl { inline void operator()( const int N, const float alpha, const T* x, T* y, CPUContext* /*context*/) { DCHECK_EQ(N, 1); *y = *x * alpha; } }; template struct AxpyImpl { inline void operator()( const int N, const float alpha, const T* x, T* y, Context* context) { Axpy(N, alpha, x, y, context); } }; // Put light-weight implementations in .h file to enable inlining template struct AxpyImpl { inline void operator()( const int N, const float alpha, const T* x, T* y, CPUContext* /*context*/) { DCHECK_EQ(N, 1); *y += *x * alpha; } }; } // namespace detail template inline void ScaleFixedSize( const int N, const float alpha, const T* x, T* y, Context* context) { detail::ScaleImpl()(N, alpha, x, y, context); } template inline void AxpyFixedSize( const int N, const float alpha, const T* x, T* y, Context* context) { detail::AxpyImpl()(N, alpha, x, y, context); } } // namespace math } // namespace caffe2 #endif // CAFFE2_UTILS_MATH_DETAIL_H_