|
|
|
|
@ -14,7 +14,9 @@ limitations under the License. */
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#if !defined(PADDLE_WITH_ARM)
|
|
|
|
|
#include <immintrin.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <cfloat>
|
|
|
|
|
#include <cmath>
|
|
|
|
|
#include <cstring>
|
|
|
|
|
@ -72,6 +74,8 @@ void call_gemm_batched(const framework::ExecutionContext& ctx,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if !defined(PADDLE_WITH_ARM)
|
|
|
|
|
|
|
|
|
|
#define __m256x __m256
|
|
|
|
|
|
|
|
|
|
static const unsigned int AVX_STEP_SIZE = 8;
|
|
|
|
|
@ -94,6 +98,8 @@ static const unsigned int SSE_CUT_LEN_MASK = 1U;
|
|
|
|
|
#define _mm_store_px _mm_storeu_ps
|
|
|
|
|
#define _mm_load1_px _mm_load1_ps
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
inline void axpy(const T* x, T* y, size_t len, const T alpha) {
|
|
|
|
|
unsigned int jjj, lll;
|
|
|
|
|
@ -108,6 +114,8 @@ inline void axpy(const T* x, T* y, size_t len, const T alpha) {
|
|
|
|
|
_mm256_add_px(_mm256_load_px(y + jjj),
|
|
|
|
|
_mm256_mul_px(mm_alpha, _mm256_load_px(x + jjj))));
|
|
|
|
|
}
|
|
|
|
|
#elif defined(PADDLE_WITH_ARM)
|
|
|
|
|
PADDLE_THROW(platform::errors::Unimplemented("axpy is not supported"));
|
|
|
|
|
#else
|
|
|
|
|
lll = len & ~SSE_CUT_LEN_MASK;
|
|
|
|
|
__m128x mm_alpha = _mm_load1_px(&alpha);
|
|
|
|
|
@ -135,6 +143,8 @@ inline void axpy_noadd(const T* x, T* y, size_t len, const T alpha) {
|
|
|
|
|
for (jjj = 0; jjj < lll; jjj += AVX_STEP_SIZE) {
|
|
|
|
|
_mm256_store_px(y + jjj, _mm256_mul_px(mm_alpha, _mm256_load_px(x + jjj)));
|
|
|
|
|
}
|
|
|
|
|
#elif defined(PADDLE_WITH_ARM)
|
|
|
|
|
PADDLE_THROW(platform::errors::Unimplemented("axpy_noadd is not supported"));
|
|
|
|
|
#else
|
|
|
|
|
lll = len & ~SSE_CUT_LEN_MASK;
|
|
|
|
|
__m128x mm_alpha = _mm_load1_px(&alpha);
|
|
|
|
|
|