SMAUG
Simulating Machine Learning Applications on gem5-Aladdin
eltwise_mul.c
2 #include "smaug/operators/smv/kernels/params.h"
4 
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8 
13 void smv_eltwise_mul_nc_vec_fxp(float16* host_inputs0,
14  float16* host_inputs1,
15  float16* host_results,
16  float* inputs0,
17  float* inputs1,
18  float* results,
19  int inputs_size) {
20  // Load inputs.
21  host_load_fp16(inputs0, host_inputs0, inputs_size, 0, 0);
22  host_load_fp16(inputs1, host_inputs1, inputs_size, 0, 0);
23 
24  VEC_ARRAY_1D(v8fp_t, _inputs0, inputs0);
25  VEC_ARRAY_1D(v8fp_t, _inputs1, inputs1);
26  VEC_ARRAY_1D(v8fp_t, _results, results);
27 
28  eltwise_mul_loop:
29  for (int i = 0; i < inputs_size / VECTOR_SIZE; i++) {
30  _results[i] = _inputs0[i] * _inputs1[i];
31  }
32 
33  // Store results to the host memory.
34  host_store_fp16(results, host_results, inputs_size, 0, 0);
35 }
36 
37 #ifdef __cplusplus
38 } // extern "C"
39 #endif
host_store_fp16
void host_store_fp16(float *local_data, float16 *remote_data, int num_elems, int local_offset, int remote_offset)
Definition: load_store_fp16_data.c:45
host_load_fp16
void host_load_fp16(float *local_data, float16 *remote_data, int num_elems, int local_offset, int remote_offset)
Definition: load_store_fp16_data.c:7
v8fp_t
fp_t v8fp_t
8 packed 32-bit floating point values.
Definition: common.h:301
load_store_fp16_data.h
Aladdin kernels to load/store FP16 data to/from host memory.
smv_eltwise_mul_nc_vec_fxp
void smv_eltwise_mul_nc_vec_fxp(float16 *host_inputs0, float16 *host_inputs1, float16 *host_results, float *inputs0, float *inputs1, float *results, int inputs_size)
Definition: eltwise_mul.c:13
common.h
Utilities for writing and invoking Aladdin kernels from Operators.
VECTOR_SIZE
#define VECTOR_SIZE
Vector size used in SMV backends.
Definition: common.h:293