Skip to content

Commit 6147f20

Browse files
Update CMSIS-NN vector_sum_s8 calls to new API (#2685)
BUG=Add rhs_offset argument
1 parent 89f99a9 commit 6147f20

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

tensorflow/lite/micro/kernels/cmsis_nn/fully_connected.cc

+6-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
147147
data->kernel_sums = static_cast<int32_t*>(
148148
context->AllocatePersistentBuffer(context, buf_size));
149149

150+
int32_t input_offset = -data->reference_op_data.input_zero_point;
151+
int32_t filter_offset = -data->reference_op_data.filter_zero_point;
150152
arm_vector_sum_s8(data->kernel_sums, filter_dims.n, data->output_depth,
151-
filter_data, 1, nullptr);
153+
filter_data, input_offset, filter_offset,
154+
tflite::GetTensorData<int32_t>(bias));
152155

153156
// Do not request a scratch buffer since using persistent memory
154157
buf_size = 0;
@@ -321,7 +324,8 @@ TfLiteStatus EvalQuantizedInt8(TfLiteContext* context, TfLiteNode* node,
321324
// If behaving like batch matmul we calculate kernel sums in eval.
322325
arm_vector_sum_s8(
323326
static_cast<int32_t*>(ctx.buf), filter_dims.n, data.output_depth,
324-
tflite::micro::GetTensorData<int8_t>(filter), 1, nullptr);
327+
tflite::micro::GetTensorData<int8_t>(filter), fc_params.input_offset,
328+
fc_params.filter_offset, bias_data);
325329
}
326330

327331
TF_LITE_ENSURE_EQ(

tensorflow/lite/micro/kernels/cmsis_nn/svdf.cc

+3-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ TfLiteStatus CmsisNnPrepareSvdf(TfLiteContext* context, TfLiteNode* node) {
193193
context->AllocatePersistentBuffer(context, buf_size));
194194

195195
arm_vector_sum_s8(data->kernel_sums, input_size, num_filters,
196-
GetTensorData<int8_t>(weights_feature), 1, nullptr);
196+
GetTensorData<int8_t>(weights_feature),
197+
-data->input_zero_point,
198+
-data->activation_state_zero_point, nullptr);
197199
}
198200

199201
} else {

tensorflow/lite/micro/kernels/cmsis_nn/unidirectional_sequence_lstm.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ LSTMBuffers<int16_t> CMSIS_NN_CreateLSTMBuffers(TfLiteContext* context,
5353
void CMSIS_NN_VectorSum(int32_t* kernel_sum, const int32_t size1,
5454
const int32_t size2, const int8_t* weights,
5555
const int32_t offset, const int32_t* biases) {
56-
arm_vector_sum_s8(kernel_sum, size1, size2, weights, offset, biases);
56+
arm_vector_sum_s8(kernel_sum, size1, size2, weights, offset, 0, biases);
5757
}
5858

5959
void CMSIS_NN_VectorSum(int64_t* kernel_sum, const int32_t size1,

tensorflow/lite/micro/tools/make/ext_libs/cmsis_nn_download.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ source ${TENSORFLOW_ROOT}tensorflow/lite/micro/tools/make/bash_helpers.sh
3838
DOWNLOADS_DIR=${1}
3939
DOWNLOADED_CMSIS_NN_PATH=${DOWNLOADS_DIR}/cmsis_nn
4040

41-
ZIP_PREFIX_NN="95f293df19c9a38806868fe12a64a4f9b457f9c1"
41+
ZIP_PREFIX_NN="f2cb41ca1450a4eb4307b2779dd5aae9028285a5"
4242
CMSIS_NN_URL="http://github.com/ARM-software/CMSIS-NN/archive/${ZIP_PREFIX_NN}.zip"
43-
CMSIS_NN_MD5="5e0c4cd60a5f074c4d26d1be236caefd"
43+
CMSIS_NN_MD5="4d0e623432d6f8d3b201cbcd89218adf"
4444

4545
should_download=$(check_should_download ${DOWNLOADS_DIR})
4646

0 commit comments

Comments
 (0)