37 OutputType *output_data)
53 const int accum_depth = filter_shape.
dims(filter_dim_count - 1);
54 for (
int b = 0; b < batches; ++b)
56 for (
int out_c = 0; out_c < output_depth; ++out_c)
59 for (
int d = 0; d < accum_depth; ++d)
61 int32_t input_val = input_data[b * accum_depth + d];
62 int32_t filter_val = filter_data[out_c * accum_depth + d];
63 acc += (filter_val + filter_offset) * (input_val + input_offset);
67 acc += bias_data[out_c];
70 acc_scaled += output_offset;
71 acc_scaled = std::max(acc_scaled, output_activation_min);
72 acc_scaled = std::min(acc_scaled, output_activation_max);
73 output_data[out_c + output_depth * b] =
static_cast<OutputType
>(acc_scaled);
82 const WeightType *filter_data,
const float *bias_data,
93 for (
int b = 0; b < batches; ++b)
96 for (
int out_c = 0; out_c < output_depth; ++out_c)
99 for (
int d = 0; d < accum_depth; ++d)
101 auto input_value = input_data[b * accum_depth + d];
102 if (std::is_same<WeightType, float>::value)
104 total += input_value * filter_data[out_c * accum_depth + d];
108 const float filter_scale = *weight_scale_ptr;
109 const float filter_value =
110 static_cast<float>(filter_data[out_c * accum_depth + d]) * filter_scale;
111 total += input_value * filter_value;
114 float bias_value = 0.0f;
117 bias_value = bias_data[out_c];
119 output_data[out_c + output_depth * b] =
120 std::min(std::max(total + bias_value, output_activation_min), output_activation_max);
122 if (std::is_same<WeightType, int8_t>::value)
OMStatus FullyConnected(const core::FullyConnectedParams ¶ms, const int16_t *input_data, const core::OMRuntimeShape &filter_shape, const int8_t *filter_data, const int64_t *bias_data, const core::OMRuntimeShape &output_shape, int16_t *output_data)