Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e-AI translator: incorrect result of fully connected operation observed when Helium (MVEI) is enabled #371

Open
SeanMeng0509 opened this issue Sep 3, 2024 · 1 comment
Assignees
Labels

Comments

@SeanMeng0509
Copy link

Issue

Due to the change of Helium support in CMSIS-NN 5.0 and later, when the e-AI translator generated model is built with Helium enabled, the fully connected operation result could be incorrect.

Workaround

If function arm_fully_connected_s8() is called by dnn_compute() in the generated file dnn_compute.c, please call arm_vector_sum_s8() to calculate vector sums first, e.g

Before adding “arm_fully_connected_s8” in “dnn_compute.c”

arm_fully_connected_s8(&cr_buffer,&layer_shapes.model_dense_MatMul_shape.fc_params,&model_dense_MatMul_multiplier,&layer_shapes.model_dense_MatMul_shape.input_dims,dnn_buffer2,&layer_shapes.model_dense_MatMul_shape.filter_dims,model_dense_MatMul_weights,&layer_shapes.model_dense_MatMul_shape.bias_dims,model_dense_MatMul_biases,&layer_shapes.model_dense_MatMul_shape.output_dims,dnn_buffer1);

arm_fully_connected_s8(&cr_buffer,&layer_shapes.model_dense_1_MatMul_shape.fc_params,&model_dense_1_MatMul_multiplier,&layer_shapes.model_dense_1_MatMul_shape.input_dims,dnn_buffer1,&layer_shapes.model_dense_1_MatMul_shape.filter_dims,model_dense_1_MatMul_weights,&layer_shapes.model_dense_1_MatMul_shape.bias_dims,model_dense_1_MatMul_biases,&layer_shapes.model_dense_1_MatMul_shape.output_dims,dnn_buffer2);

After adding “arm_fully_connected_s8” in “dnn_compute.c”

arm_vector_sum_s8(cr_buffer.buf, layer_shapes.model_dense_MatMul_shape.filter_dims.n, layer_shapes.model_dense_MatMul_shape.output_dims.c, model_dense_MatMul_weights);
arm_fully_connected_s8(&cr_buffer,&layer_shapes.model_dense_MatMul_shape.fc_params,&model_dense_MatMul_multiplier,&layer_shapes.model_dense_MatMul_shape.input_dims,dnn_buffer2,&layer_shapes.model_dense_MatMul_shape.filter_dims,model_dense_MatMul_weights,&layer_shapes.model_dense_MatMul_shape.bias_dims,model_dense_MatMul_biases,&layer_shapes.model_dense_MatMul_shape.output_dims,dnn_buffer1);

arm_vector_sum_s8(cr_buffer.buf, layer_shapes.model_dense_1_MatMul_shape.filter_dims.n, layer_shapes.model_dense_1_MatMul_shape.output_dims.c, model_dense_1_MatMul_weights);
arm_fully_connected_s8(&cr_buffer,&layer_shapes.model_dense_1_MatMul_shape.fc_params,&model_dense_1_MatMul_multiplier,&layer_shapes.model_dense_1_MatMul_shape.input_dims,dnn_buffer1,&layer_shapes.model_dense_1_MatMul_shape.filter_dims,model_dense_1_MatMul_weights,&layer_shapes.model_dense_1_MatMul_shape.bias_dims,model_dense_1_MatMul_biases,&layer_shapes.model_dense_1_MatMul_shape.output_dims,dnn_buffer2);
@SeanMeng0509
Copy link
Author

This is being internally tracked using RAP-3211.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant