1010#pragma once
1111
1212#include < c10/util/irange.h>
13+ #include < executorch/runtime/platform/compiler.h>
1314#include < algorithm>
1415#include < cmath>
1516#include < cstdint>
@@ -45,9 +46,9 @@ inline float vec_maxf(const float* x, size_t size) {
4546// / Add each element of `x` and `y` into the corresponding element of `z`. All
4647// / arrays must have `size` elements.
4748inline void vec_addf (
48- float * __restrict__ z,
49- const float * __restrict__ x,
50- const float * __restrict__ y,
49+ float * ET_RESTRICT z,
50+ const float * ET_RESTRICT x,
51+ const float * ET_RESTRICT y,
5152 size_t size) {
5253 for (const auto i : c10::irange (size)) {
5354 z[i] = x[i] + y[i];
@@ -57,8 +58,8 @@ inline void vec_addf(
5758// / Multiplies every element of `x` by `scale`, and writes the result into the
5859// / corresponding element of `y`. `x` and `y` must have `size` elements.
5960inline void vec_scalef (
60- float * __restrict__ y,
61- const float * __restrict__ x,
61+ float * ET_RESTRICT y,
62+ const float * ET_RESTRICT x,
6263 float scale,
6364 size_t size) {
6465 for (const auto i : c10::irange (size)) {
@@ -70,9 +71,9 @@ inline void vec_scalef(
7071// / z[i][j] = sum(x[i][k] * y[k][j])
7172template <typename T, typename U = T>
7273inline void vec_matmul (
73- T* __restrict__ z,
74- const U* __restrict__ x,
75- const U* __restrict__ y,
74+ T* ET_RESTRICT z,
75+ const U* ET_RESTRICT x,
76+ const U* ET_RESTRICT y,
7677 int64_t m,
7778 int64_t n,
7879 int64_t p) {
@@ -89,10 +90,10 @@ inline void vec_matmul(
8990
9091template <typename T, typename U = T>
9192inline void vec_quantized_matmul_int8 (
92- T* __restrict__ z,
93- const U* __restrict__ x,
94- const int8_t * __restrict__ y,
95- const U* __restrict__ s,
93+ T* ET_RESTRICT z,
94+ const U* ET_RESTRICT x,
95+ const int8_t * ET_RESTRICT y,
96+ const U* ET_RESTRICT s,
9697 int64_t m,
9798 int64_t n,
9899 int64_t p) {
@@ -115,10 +116,10 @@ static inline size_t bounds_min(size_t a, size_t b) {
115116// / z[i][j] = sum(x[i][k] * y[j][k] * s[j][k/g])
116117template <typename T, typename U = T, typename V = U>
117118inline void vec_quantized_matmul_transb_int8 (
118- T* __restrict__ z,
119- const U* __restrict__ x,
120- const int8_t * __restrict__ y,
121- const V* __restrict__ s,
119+ T* ET_RESTRICT z,
120+ const U* ET_RESTRICT x,
121+ const int8_t * ET_RESTRICT y,
122+ const V* ET_RESTRICT s,
122123 int64_t m,
123124 int64_t n,
124125 int64_t p,
@@ -146,10 +147,10 @@ inline void vec_quantized_matmul_transb_int8(
146147// T for tensor dtype, U for scalar type
147148template <typename T, typename U = T>
148149inline void vec_addmm (
149- T* __restrict__ out_data,
150- const T* __restrict__ self_data,
151- const T* __restrict__ mat1_data,
152- const T* __restrict__ mat2_data,
150+ T* ET_RESTRICT out_data,
151+ const T* ET_RESTRICT self_data,
152+ const T* ET_RESTRICT mat1_data,
153+ const T* ET_RESTRICT mat2_data,
153154 int64_t m,
154155 int64_t n,
155156 int64_t p,
@@ -195,7 +196,7 @@ template <
195196 typename checkU = typename std::enable_if<
196197 std::is_same<float , typename std::remove_cv<U>::type>::value ||
197198 std::is_same<double , typename std::remove_cv<U>::type>::value>::type>
198- inline void vec_softmax (T* __restrict__ y, const U* __restrict__ x, int n) {
199+ inline void vec_softmax (T* ET_RESTRICT y, const U* ET_RESTRICT x, int n) {
199200 U max_x = *std::max_element (x, x + n);
200201 T sum = 0 ;
201202
@@ -223,8 +224,8 @@ constexpr const T& clamp(const T& v, const T& lo, const T& hi) {
223224// / Quantizes the elements of `x` into `y`, both of which must have `size`
224225// / elements. Inverse of `dequantize_i8_f32()`.
225226inline void quantize_i8_f32 (
226- int8_t * __restrict__ y,
227- const float * __restrict__ x,
227+ int8_t * ET_RESTRICT y,
228+ const float * ET_RESTRICT x,
228229 float scale,
229230 int32_t zero_point,
230231 size_t size) {
@@ -237,8 +238,8 @@ inline void quantize_i8_f32(
237238// / Dequantizes the elements of `x` into `y`, both of which must have `size`
238239// / elements. Inverse of `quantize_i8_f32()`.
239240inline void dequantize_i8_f32 (
240- float * __restrict__ y,
241- const int8_t * __restrict__ x,
241+ float * ET_RESTRICT y,
242+ const int8_t * ET_RESTRICT x,
242243 float scale,
243244 int32_t zero_point,
244245 size_t size) {
0 commit comments