diff --git a/onert-micro/onert-micro/include/OMStatus.h b/onert-micro/onert-micro/include/OMStatus.h index 7534febfa6d..66005fbe589 100644 --- a/onert-micro/onert-micro/include/OMStatus.h +++ b/onert-micro/onert-micro/include/OMStatus.h @@ -34,6 +34,7 @@ enum OMStatus UnsupportedDynamicShapeCase, FailReadWOFFile, FailReadCheckpointFile, + CmsisNNError, }; } // namespace onert_micro diff --git a/onert-micro/onert-micro/include/pal/cmsisnn/KernelsToBuild.lst b/onert-micro/onert-micro/include/pal/cmsisnn/KernelsToBuild.lst index e69de29bb2d..049a77a140e 100644 --- a/onert-micro/onert-micro/include/pal/cmsisnn/KernelsToBuild.lst +++ b/onert-micro/onert-micro/include/pal/cmsisnn/KernelsToBuild.lst @@ -0,0 +1,87 @@ +#/*REGISTER_KERNEL(ABS, Abs)*/ +#/*REGISTER_KERNEL(ADD, Add)*/ +#/*REGISTER_KERNEL(ADD_N, AddN)*/ +#/*REGISTER_KERNEL(AVERAGE_POOL_2D, AveragePool2D)*/ +#/*REGISTER_KERNEL(ARG_MAX, ArgMax)*/ +#/*REGISTER_KERNEL(ARG_MIN, ArgMin)*/ +#/*REGISTER_KERNEL(CONCATENATION, Concatenation)*/ +#/*REGISTER_KERNEL(CUSTOM, BroadcastTo)*/ +#/*REGISTER_KERNEL(BATCH_TO_SPACE_ND, BatchToSpaceND)*/ +#/*REGISTER_KERNEL(CEIL, Ceil)*/ +#/*REGISTER_KERNEL(COS, Cos)*/ +#/*REGISTER_KERNEL(CAST, Cast)*/ +#/*REGISTER_KERNEL(DIV, Div)*/ +#/*REGISTER_KERNEL(DEPTHWISE_CONV_2D, DepthwiseConv2D)*/ +#/*REGISTER_KERNEL(DEPTH_TO_SPACE, DepthToSpace)*/ +#/*REGISTER_KERNEL(DEQUANTIZE, Dequantize)*/ +REGISTER_KERNEL(FULLY_CONNECTED, FullyConnected) +#/*REGISTER_KERNEL(CONV_2D, Conv2D)*/ +#/*REGISTER_KERNEL(LOGISTIC, Logistic)*/ +#/*REGISTER_KERNEL(LOG, Log)*/ +#/*REGISTER_KERNEL(GATHER, Gather)*/ +#/*REGISTER_KERNEL(GATHER_ND, GatherND)*/ +#/*REGISTER_KERNEL(EXP, Exp)*/ +#/*REGISTER_KERNEL(GREATER, Greater)*/ +#/*REGISTER_KERNEL(GREATER_EQUAL, GreaterEqual)*/ +#/*REGISTER_KERNEL(EXPAND_DIMS, ExpandDims)*/ +#/*REGISTER_KERNEL(ELU, Elu)*/ +#/*REGISTER_KERNEL(EQUAL, Equal)*/ +#/*REGISTER_KERNEL(FILL, Fill)*/ +#/*REGISTER_KERNEL(FLOOR, Floor)*/ +#/*REGISTER_KERNEL(FLOOR_DIV, FloorDiv)*/ +#/*REGISTER_KERNEL(FLOOR_MOD, FloorMod)*/ +#/*REGISTER_KERNEL(PACK, Pack)*/ +#/*REGISTER_KERNEL(PAD, Pad)*/ +#/*REGISTER_KERNEL(PADV2, PadV2)*/ +#/*REGISTER_KERNEL(PRELU, PRelu)*/ +#/*REGISTER_KERNEL(RESHAPE, Reshape)*/ +#/*REGISTER_KERNEL(RELU, Relu)*/ +#/*REGISTER_KERNEL(RELU6, Relu6)*/ +#/*REGISTER_KERNEL(REDUCE_PROD, ReduceCommon)*/ +#/*REGISTER_KERNEL(REDUCE_MAX, ReduceMax)*/ +#/*REGISTER_KERNEL(ROUND, Round)*/ +#/*REGISTER_KERNEL(LESS, Less)*/ +#/*REGISTER_KERNEL(L2_NORMALIZATION, L2Normalize)*/ +#/*REGISTER_KERNEL(L2_POOL_2D, L2Pool2D)*/ +#/*REGISTER_KERNEL(LESS_EQUAL, LessEqual)*/ +#/*REGISTER_KERNEL(LOGICAL_AND, LogicalAnd)*/ +#/*REGISTER_KERNEL(LOGICAL_NOT, LogicalNot)*/ +#/*REGISTER_KERNEL(LOGICAL_OR, LogicalOr)*/ +#/*REGISTER_KERNEL(LEAKY_RELU, LeakyRelu)*/ +#/*REGISTER_KERNEL(LOG_SOFTMAX, LogSoftmax)*/ +#/*REGISTER_KERNEL(MUL, Mul)*/ +#/*REGISTER_KERNEL(MIRROR_PAD, MirrorPad)*/ +#/*REGISTER_KERNEL(MAXIMUM, Maximum)*/ +#/*REGISTER_KERNEL(MEAN, Mean)*/ +#/*REGISTER_KERNEL(MAX_POOL_2D, MaxPool2D)*/ +#/*REGISTER_KERNEL(MINIMUM, Minimum)*/ +#/*REGISTER_KERNEL(SHAPE, Shape)*/ +#/*REGISTER_KERNEL(NOT_EQUAL, NotEqual)*/ +#/*REGISTER_KERNEL(SIN, Sin)*/ +#/*REGISTER_KERNEL(SQUARED_DIFFERENCE, SquaredDifference)*/ +#/*REGISTER_KERNEL(SLICE, Slice)*/ +#/*REGISTER_KERNEL(SUB, Sub)*/ +#/*REGISTER_KERNEL(SPLIT, Split)*/ +#/*REGISTER_KERNEL(SPACE_TO_BATCH_ND, SpaceToBatchND)*/ +#/*REGISTER_KERNEL(STRIDED_SLICE, StridedSlice)*/ +#/*REGISTER_KERNEL(SPLIT_V, SplitV)*/ +#/*REGISTER_KERNEL(SQUARE, Square)*/ +#/*REGISTER_KERNEL(SQRT, Sqrt)*/ +#/*REGISTER_KERNEL(SPACE_TO_DEPTH, SpaceToDepth)*/ +#/*REGISTER_KERNEL(QUANTIZE, Quantize)*/ +#/*REGISTER_KERNEL(TANH, Tanh)*/ +#/*REGISTER_KERNEL(TRANSPOSE, Transpose)*/ +#/*REGISTER_KERNEL(TRANSPOSE_CONV, TransposeConv)*/ +#/*REGISTER_KERNEL(SOFTMAX, Softmax)*/ +#/*REGISTER_KERNEL(SUM, Sum)*/ +#/*REGISTER_KERNEL(SELECT_V2, SelectV2)*/ +#/*REGISTER_KERNEL(SVDF, SVDF)*/ +#/*REGISTER_KERNEL(WHILE, While)*/ +#/*REGISTER_KERNEL(UNIDIRECTIONAL_SEQUENCE_LSTM, UnidirectionalSequenceLSTM)*/ +#/*REGISTER_KERNEL(RESIZE_BILINEAR, ResizeBilinear)*/ +#/*REGISTER_KERNEL(RESIZE_NEAREST_NEIGHBOR, ResizeNearestNeighbor)*/ +#/*REGISTER_KERNEL(RSQRT, Rsqrt)*/ +#/*REGISTER_KERNEL(NEG, Neg)*/ +#/*REGISTER_KERNEL(ZEROS_LIKE, ZerosLike)*/ +#/*REGISTER_KERNEL(SQUEEZE, Squeeze)*/ +#/*REGISTER_KERNEL(UNPACK, Unpack)*/ diff --git a/onert-micro/onert-micro/include/pal/cmsisnn/PALFullyConnected.h b/onert-micro/onert-micro/include/pal/cmsisnn/PALFullyConnected.h new file mode 100644 index 00000000000..cbd8510d0dd --- /dev/null +++ b/onert-micro/onert-micro/include/pal/cmsisnn/PALFullyConnected.h @@ -0,0 +1,168 @@ +/* + * Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved + * Copyright 2017 The TensorFlow Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ONERT_MICRO_EXECUTE_PAL_FULLY_CONNECTED_H +#define ONERT_MICRO_EXECUTE_PAL_FULLY_CONNECTED_H + +#include "PALFullyConnectedCommon.h" + +#include + +namespace onert_micro +{ +namespace execute +{ +namespace pal +{ +template <> +OMStatus FullyConnected(const core::FullyConnectedParams ¶ms, const int8_t *input_data, + const core::OMRuntimeShape &filter_shape, const int8_t *filter_data, + const int32_t *bias_data, const core::OMRuntimeShape &output_shape, + int8_t *output_data) +{ + const int filter_dim_count = filter_shape.dimensionsCount(); + const int output_dim_count = output_shape.dimensionsCount(); + const int batches = + flatSizeSkipDim(output_shape.dimsData(), output_dim_count - 1, output_dim_count); + const int output_depth = output_shape.dims(output_dim_count - 1); + const int accum_depth = filter_shape.dims(filter_dim_count - 1); + + cmsis_nn_fc_params fc_params; + fc_params.input_offset = params.input_offset; + fc_params.output_offset = params.output_offset; + fc_params.filter_offset = params.weights_offset; + fc_params.activation.min = params.quantized_activation_min; + fc_params.activation.max = params.quantized_activation_max; + + cmsis_nn_per_tensor_quant_params quant_params; + quant_params.multiplier = params.output_multiplier; + quant_params.shift = params.output_shift; + + cmsis_nn_dims input_dims; + input_dims.n = batches; + input_dims.h = 1; + input_dims.w = 1; + input_dims.c = accum_depth; + + cmsis_nn_dims filter_dims; + filter_dims.n = accum_depth; + filter_dims.h = 1; + filter_dims.w = 1; + filter_dims.c = output_depth; + + cmsis_nn_dims bias_dims; + bias_dims.n = 1; + bias_dims.h = 1; + bias_dims.w = 1; + bias_dims.c = output_depth; + + cmsis_nn_dims output_dims; + output_dims.n = batches; + output_dims.h = 1; + output_dims.w = 1; + output_dims.c = output_depth; + + int32_t buf_size = arm_fully_connected_s8_get_buffer_size(&filter_dims); + auto buffer = std::make_unique(buf_size); + assert(buffer != nullptr); + + cmsis_nn_context ctx; + ctx.buf = buffer.get(); + ctx.size = buf_size; + + auto res = + arm_fully_connected_s8(&ctx, &fc_params, &quant_params, &input_dims, input_data, &filter_dims, + filter_data, &bias_dims, bias_data, &output_dims, output_data); + assert(res == ARM_CMSIS_NN_SUCCESS); + if (res != ARM_CMSIS_NN_SUCCESS) + return CmsisNNError; + + return Ok; +} + +template <> +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) +{ + const int filter_dim_count = filter_shape.dimensionsCount(); + const int output_dim_count = output_shape.dimensionsCount(); + const int batches = + flatSizeSkipDim(output_shape.dimsData(), output_dim_count - 1, output_dim_count); + const int output_depth = output_shape.dims(output_dim_count - 1); + const int accum_depth = filter_shape.dims(filter_dim_count - 1); + + cmsis_nn_fc_params fc_params; + fc_params.input_offset = params.input_offset; + fc_params.output_offset = params.output_offset; + fc_params.filter_offset = params.weights_offset; + fc_params.activation.min = params.quantized_activation_min; + fc_params.activation.max = params.quantized_activation_max; + + cmsis_nn_per_tensor_quant_params quant_params; + quant_params.multiplier = params.output_multiplier; + quant_params.shift = params.output_shift; + + cmsis_nn_dims input_dims; + input_dims.n = batches; + input_dims.h = 1; + input_dims.w = 1; + input_dims.c = accum_depth; + + cmsis_nn_dims filter_dims; + filter_dims.n = accum_depth; + filter_dims.h = 1; + filter_dims.w = 1; + filter_dims.c = output_depth; + + cmsis_nn_dims bias_dims; + bias_dims.n = 1; + bias_dims.h = 1; + bias_dims.w = 1; + bias_dims.c = output_depth; + + cmsis_nn_dims output_dims; + output_dims.n = batches; + output_dims.h = 1; + output_dims.w = 1; + output_dims.c = output_depth; + + int32_t buf_size = arm_fully_connected_s16_get_buffer_size(&filter_dims); + auto buffer = std::make_unique(buf_size); + assert(buffer != nullptr); + + cmsis_nn_context ctx; + ctx.buf = buffer.get(); + ctx.size = buf_size; + + auto res = + arm_fully_connected_s16(&ctx, &fc_params, &quant_params, &input_dims, input_data, &filter_dims, + filter_data, &bias_dims, bias_data, &output_dims, output_data); + assert(res == ARM_CMSIS_NN_SUCCESS); + + if (res != ARM_CMSIS_NN_SUCCESS) + return CmsisNNError; + + return Ok; +} + +} // namespace pal +} // namespace execute +} // namespace onert_micro + +#endif // ONERT_MICRO_EXECUTE_PAL_FULLY_CONNECTED_COMMON_H diff --git a/onert-micro/onert-micro/include/test_models/fully_connected/NegFullyConnectedKernel.h b/onert-micro/onert-micro/include/test_models/fully_connected/NegFullyConnectedKernel.h index 9dcaa5d0edd..aa2465b200f 100644 --- a/onert-micro/onert-micro/include/test_models/fully_connected/NegFullyConnectedKernel.h +++ b/onert-micro/onert-micro/include/test_models/fully_connected/NegFullyConnectedKernel.h @@ -117,6 +117,132 @@ const unsigned char test_kernel_model_circle[] = { 0x65, 0x00, 0x00, 0x00}; } // namespace neg_fully_connected_wrong_bias_shape +namespace neg_fully_connected_no_zero_points +{ +/* + * FullyConnected Kernel with quantize type and without zero points + * + * Input(1, 64)-Int16 Weight(8, 64) - Int16 + * \ | + * \ | + * FullyConnected --- Bias (8) - Int32 + * | + * Output(1, 8) - Int16 + */ + +const unsigned char test_kernel_model_circle[] = { + 0x18, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x70, 0x04, 0x00, 0x00, 0x80, 0x06, 0x00, 0x00, 0x9c, 0x06, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x5c, 0x04, 0x00, 0x00, 0x54, 0x04, 0x00, 0x00, 0x4c, 0x04, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0xd2, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xfd, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, + 0xf9, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0xfc, 0xff, 0xfa, 0xff, 0x03, 0x00, 0xff, 0xff, + 0x03, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x02, 0x00, 0xfc, 0xff, 0x08, 0x00, + 0xfd, 0xff, 0x05, 0x00, 0x00, 0x00, 0xfa, 0xff, 0xfc, 0xff, 0xfb, 0xff, 0x04, 0x00, 0xfa, 0xff, + 0xf8, 0xff, 0x01, 0x00, 0xfc, 0xff, 0xfb, 0xff, 0x00, 0x00, 0xfb, 0xff, 0x01, 0x00, 0x04, 0x00, + 0x04, 0x00, 0xfd, 0xff, 0x00, 0x00, 0xfc, 0xff, 0xfe, 0xff, 0x01, 0x00, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfd, 0xff, 0x04, 0x00, 0xf6, 0xff, 0xfa, 0xff, 0xfb, 0xff, 0x05, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xf7, 0xff, 0xfd, 0xff, 0x04, 0x00, 0x03, 0x00, 0x02, 0x00, + 0xfd, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0xfb, 0xff, 0x04, 0x00, + 0xfd, 0xff, 0x02, 0x00, 0x05, 0x00, 0x04, 0x00, 0xfd, 0xff, 0x04, 0x00, 0xfa, 0xff, 0x03, 0x00, + 0x05, 0x00, 0x00, 0x00, 0xfa, 0xff, 0xfb, 0xff, 0x08, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xf8, 0xff, 0x05, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0x03, 0x00, 0xf7, 0xff, + 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x06, 0x00, 0xfb, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x04, 0x00, 0xf9, 0xff, 0xfb, 0xff, 0xfd, 0xff, 0xf5, 0xff, 0x07, 0x00, 0x04, 0x00, + 0x01, 0x00, 0xf6, 0xff, 0xfa, 0xff, 0x02, 0x00, 0x07, 0x00, 0xff, 0xff, 0xff, 0xff, 0x07, 0x00, + 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0xff, 0xff, 0x02, 0x00, 0x04, 0x00, 0x04, 0x00, + 0x05, 0x00, 0x07, 0x00, 0xf7, 0xff, 0x09, 0x00, 0x00, 0x00, 0xfd, 0xff, 0x06, 0x00, 0x05, 0x00, + 0x00, 0x00, 0xfb, 0xff, 0x01, 0x00, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfd, 0xff, 0x00, 0x00, + 0x07, 0x00, 0xff, 0xff, 0x00, 0x00, 0x03, 0x00, 0xfd, 0xff, 0xff, 0xff, 0x00, 0x00, 0xf9, 0xff, + 0x06, 0x00, 0x00, 0x00, 0xfb, 0xff, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xff, 0x04, 0x00, 0xfd, 0xff, + 0x02, 0x00, 0xfa, 0xff, 0x01, 0x00, 0xf9, 0xff, 0xfa, 0xff, 0x00, 0x00, 0x00, 0x00, 0xf2, 0xff, + 0xf3, 0xff, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0xff, 0xff, 0xfd, 0xff, 0x04, 0x00, 0x05, 0x00, + 0x03, 0x00, 0x06, 0x00, 0xfb, 0xff, 0xfc, 0xff, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xfe, 0xff, + 0xfe, 0xff, 0x01, 0x00, 0xf9, 0xff, 0x08, 0x00, 0x02, 0x00, 0x01, 0x00, 0x05, 0x00, 0xfd, 0xff, + 0xfe, 0xff, 0xfd, 0xff, 0x03, 0x00, 0xfe, 0xff, 0x02, 0x00, 0xfa, 0xff, 0x04, 0x00, 0x00, 0x00, + 0xfb, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0x04, 0x00, 0xff, 0xff, 0x02, 0x00, 0x0b, 0x00, 0x01, 0x00, + 0x07, 0x00, 0xfe, 0xff, 0x06, 0x00, 0xf2, 0xff, 0x02, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x01, 0x00, + 0xfc, 0xff, 0x0a, 0x00, 0x03, 0x00, 0x02, 0x00, 0xf7, 0xff, 0x00, 0x00, 0xfb, 0xff, 0x01, 0x00, + 0xfb, 0xff, 0x01, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, + 0xfc, 0xff, 0x05, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xf9, 0xff, 0x05, 0x00, 0xff, 0xff, + 0x07, 0x00, 0xff, 0xff, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0xf7, 0xff, 0x01, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0xf7, 0xff, 0xff, 0xff, 0x04, 0x00, 0x04, 0x00, + 0x02, 0x00, 0x03, 0x00, 0xfd, 0xff, 0xfa, 0xff, 0xfb, 0xff, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xfd, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfa, 0xff, 0xf8, 0xff, 0x05, 0x00, 0xff, 0xff, + 0xfb, 0xff, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00, 0x02, 0x00, 0xfb, 0xff, 0x04, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xf7, 0xff, 0xf0, 0xff, 0x00, 0x00, 0xfb, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, + 0x05, 0x00, 0x01, 0x00, 0x04, 0x00, 0xfe, 0xff, 0xfa, 0xff, 0x07, 0x00, 0xfb, 0xff, 0xf6, 0xff, + 0xff, 0xff, 0x07, 0x00, 0xfd, 0xff, 0x02, 0x00, 0x0b, 0x00, 0x04, 0x00, 0xff, 0xff, 0xfb, 0xff, + 0x02, 0x00, 0x03, 0x00, 0xfd, 0xff, 0x02, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xff, 0xff, 0x05, 0x00, + 0x09, 0x00, 0xfc, 0xff, 0xfd, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x02, 0x00, + 0xfd, 0xff, 0x03, 0x00, 0x04, 0x00, 0x01, 0x00, 0x01, 0x00, 0xfd, 0xff, 0x01, 0x00, 0xfe, 0xff, + 0x06, 0x00, 0xff, 0xff, 0x05, 0x00, 0xfe, 0xff, 0xfd, 0xff, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, + 0x03, 0x00, 0x0b, 0x00, 0xfa, 0xff, 0xfe, 0xff, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0xfd, 0xff, + 0xfe, 0xff, 0x02, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xfd, 0xff, 0xff, 0xff, + 0xfc, 0xff, 0x04, 0x00, 0x01, 0x00, 0x01, 0x00, 0xfb, 0xff, 0x02, 0x00, 0x03, 0x00, 0x06, 0x00, + 0xfc, 0xff, 0xfe, 0xff, 0x01, 0x00, 0x07, 0x00, 0xfc, 0xff, 0xfd, 0xff, 0x02, 0x00, 0x05, 0x00, + 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x02, 0x00, 0x04, 0x00, 0xfc, 0xff, + 0x02, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xfd, 0xff, 0x00, 0x00, 0xf5, 0xff, + 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x01, 0x00, 0x06, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0x00, + 0xfd, 0xff, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0xfa, 0xff, 0xfd, 0xff, 0x05, 0x00, 0x02, 0x00, + 0xf9, 0xff, 0xfc, 0xff, 0xff, 0xff, 0x00, 0x00, 0xfd, 0xff, 0xfc, 0xff, 0x07, 0x00, 0x03, 0x00, + 0xfd, 0xff, 0xfd, 0xff, 0x09, 0x00, 0x00, 0x00, 0xfb, 0xff, 0x02, 0x00, 0x02, 0x00, 0x07, 0x00, + 0xfb, 0xff, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x00, 0x03, 0x00, 0x06, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xfc, 0xff, 0xfe, 0xff, 0x02, 0x00, 0x03, 0x00, 0xf6, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xfd, 0xff, 0x04, 0x00, 0xfe, 0xff, 0xfd, 0xff, 0x03, 0x00, 0xff, 0xff, 0x05, 0x00, + 0x00, 0x00, 0xfe, 0xff, 0xfd, 0xff, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, + 0x05, 0x00, 0x07, 0x00, 0xf4, 0xff, 0x0a, 0x00, 0x06, 0x00, 0x07, 0x00, 0x02, 0x00, 0x03, 0x00, + 0xfd, 0xff, 0x08, 0x00, 0xfb, 0xff, 0x04, 0x00, 0x07, 0x00, 0x0a, 0x00, 0xfb, 0xff, 0x03, 0x00, + 0x04, 0x00, 0x04, 0x00, 0xfe, 0xff, 0x02, 0x00, 0x00, 0x00, 0xf7, 0xff, 0x02, 0x00, 0x01, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0xfd, 0xff, 0x04, 0x00, 0xfd, 0xff, 0x00, 0x00, + 0xfb, 0xff, 0xf7, 0xff, 0xfa, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x07, 0x00, 0x05, 0x00, + 0xfe, 0xff, 0xfb, 0xff, 0xf8, 0xff, 0x0b, 0x00, 0x02, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, + 0x01, 0x00, 0x09, 0x00, 0x0c, 0x00, 0x05, 0x00, 0x01, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x01, 0x00, 0x07, 0x00, 0x04, 0x00, 0x07, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xfb, 0xff, + 0xfb, 0xff, 0xff, 0xff, 0xfe, 0xff, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x02, 0x00, 0xff, 0xff, + 0x00, 0x00, 0x04, 0x00, 0x8c, 0xff, 0xff, 0xff, 0x90, 0xff, 0xff, 0xff, 0x94, 0xff, 0xff, 0xff, + 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, + 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0c, 0x00, + 0x07, 0x00, 0x08, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, + 0x9c, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0e, 0xff, 0xff, 0xff, + 0x14, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x3c, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xb8, 0x19, 0x85, 0x39, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0f, 0x00, + 0x08, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x62, 0x69, 0x61, 0x73, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x9e, 0xff, 0xff, 0xff, + 0x14, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x40, 0x00, 0x00, 0x00, 0x90, 0xff, 0xff, 0xff, 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xdd, 0x58, 0xa4, 0x3a, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x18, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + 0x48, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x7e, 0x87, 0xb9, 0x39, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x0c, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x09, 0x11, 0x00, 0x00, 0x00, 0x4f, 0x4e, 0x45, 0x2d, 0x74, 0x66, 0x6c, 0x69, + 0x74, 0x65, 0x32, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x00, 0x00, 0x00}; +} // namespace neg_fully_connected_no_zero_points + class NegTestDataWrongWeightShapeFullyConnectedKernel : public NegTestDataBase { public: @@ -149,6 +275,22 @@ class NegTestDataWrongBiasShapeFullyConnectedKernel : public NegTestDataBase const unsigned char *_test_kernel_model_circle; }; +class NegTestDataNoZeroPointsFullyConnectedKernel : public NegTestDataBase +{ +public: + NegTestDataNoZeroPointsFullyConnectedKernel() + { + _test_kernel_model_circle = neg_fully_connected_no_zero_points::test_kernel_model_circle; + } + + ~NegTestDataNoZeroPointsFullyConnectedKernel() override = default; + + const unsigned char *get_model_ptr() override final { return _test_kernel_model_circle; } + +protected: + const unsigned char *_test_kernel_model_circle; +}; + } // namespace test_model } // namespace onert_micro diff --git a/onert-micro/onert-micro/include/test_models/fully_connected/QuantFullyConnectedKernel.h b/onert-micro/onert-micro/include/test_models/fully_connected/QuantFullyConnectedKernel.h index c84aed4c6b8..043aae4a9cf 100644 --- a/onert-micro/onert-micro/include/test_models/fully_connected/QuantFullyConnectedKernel.h +++ b/onert-micro/onert-micro/include/test_models/fully_connected/QuantFullyConnectedKernel.h @@ -122,6 +122,144 @@ const std::vector reference_output_data = {-128, -128, 127, 96, 127, 127 } // namespace s8_fully_connected +namespace s16_fully_connected +{ + +/* + * S16 FullyConnected Kernel: + * + * Input(1, 64)-Int16 Weight(8, 64) - Int16 + * \ | + * \ | + * FullyConnected --- Bias (8) - Int32 + * | + * Output(1, 8) - Int16 + */ + +const unsigned char test_kernel_model_circle[] = { + 0x1c, 0x00, 0x00, 0x00, 0x43, 0x49, 0x52, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x10, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x70, 0x04, 0x00, 0x00, 0xa0, 0x06, 0x00, 0x00, 0xbc, 0x06, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x5c, 0x04, 0x00, 0x00, 0x54, 0x04, 0x00, 0x00, 0x4c, 0x04, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0xd2, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x06, 0x00, 0x08, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0xfe, 0xff, 0x02, 0x00, 0xff, 0xff, 0xff, 0xff, + 0xfe, 0xff, 0x00, 0x00, 0x01, 0x00, 0x06, 0x00, 0xfb, 0xff, 0xf7, 0xff, 0x02, 0x00, 0xf9, 0xff, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x06, 0x00, 0x01, 0x00, 0xf7, 0xff, + 0x06, 0x00, 0x04, 0x00, 0x06, 0x00, 0xfe, 0xff, 0x05, 0x00, 0xfa, 0xff, 0xfd, 0xff, 0xff, 0xff, + 0xfd, 0xff, 0xfc, 0xff, 0xfe, 0xff, 0x03, 0x00, 0xfa, 0xff, 0x0a, 0x00, 0xfe, 0xff, 0x00, 0x00, + 0x00, 0x00, 0xfa, 0xff, 0x00, 0x00, 0xfd, 0xff, 0x01, 0x00, 0x02, 0x00, 0x0f, 0x00, 0xff, 0xff, + 0xfd, 0xff, 0x03, 0x00, 0x09, 0x00, 0xfe, 0xff, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, + 0x00, 0x00, 0x03, 0x00, 0xf6, 0xff, 0x00, 0x00, 0x06, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, + 0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x04, 0x00, 0xfa, 0xff, 0x04, 0x00, 0x05, 0x00, 0xfe, 0xff, + 0x01, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x08, 0x00, + 0xfa, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xf9, 0xff, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x02, 0x00, 0xff, 0xff, 0x00, 0x00, 0x04, 0x00, 0xfd, 0xff, 0xfd, 0xff, 0xf9, 0xff, 0x01, 0x00, + 0x04, 0x00, 0x03, 0x00, 0xf4, 0xff, 0xff, 0xff, 0x05, 0x00, 0xf9, 0xff, 0x01, 0x00, 0x01, 0x00, + 0x09, 0x00, 0xf8, 0xff, 0x00, 0x00, 0xf8, 0xff, 0x04, 0x00, 0xf8, 0xff, 0x08, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0xf9, 0xff, 0xff, 0xff, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0xf8, 0xff, + 0x01, 0x00, 0x01, 0x00, 0xf5, 0xff, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 0xff, 0xff, 0x02, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xf6, 0xff, 0x05, 0x00, 0xfd, 0xff, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03, 0x00, 0x01, 0x00, 0xfd, 0xff, 0xff, 0xff, 0x02, 0x00, + 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xfc, 0xff, 0x00, 0x00, 0xfa, 0xff, 0xfd, 0xff, + 0x00, 0x00, 0x02, 0x00, 0xfa, 0xff, 0x05, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, + 0xfe, 0xff, 0x02, 0x00, 0xf8, 0xff, 0x04, 0x00, 0xf9, 0xff, 0x08, 0x00, 0x02, 0x00, 0x05, 0x00, + 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xff, 0x06, 0x00, 0x02, 0x00, + 0x08, 0x00, 0x0a, 0x00, 0x05, 0x00, 0xfd, 0xff, 0xfd, 0xff, 0xfe, 0xff, 0x02, 0x00, 0xfe, 0xff, + 0xfc, 0xff, 0xfc, 0xff, 0xfa, 0xff, 0x05, 0x00, 0x01, 0x00, 0x04, 0x00, 0xfc, 0xff, 0xfd, 0xff, + 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x01, 0x00, 0x06, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x01, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xfb, 0xff, 0x01, 0x00, 0xfa, 0xff, 0x00, 0x00, 0xfb, 0xff, 0x03, 0x00, + 0x05, 0x00, 0xfc, 0xff, 0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xfd, 0xff, 0x02, 0x00, 0xfe, 0xff, + 0xfd, 0xff, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0xfa, 0xff, 0xfd, 0xff, 0x03, 0x00, 0x00, 0x00, + 0x09, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xfe, 0xff, 0xfa, 0xff, 0x01, 0x00, + 0xf8, 0xff, 0xf8, 0xff, 0xff, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfa, 0xff, 0x05, 0x00, 0x04, 0x00, + 0x03, 0x00, 0xfa, 0xff, 0x05, 0x00, 0xfb, 0xff, 0x07, 0x00, 0xfc, 0xff, 0xfd, 0xff, 0x05, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xf6, 0xff, 0xfc, 0xff, 0x05, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0x05, 0x00, 0x00, 0x00, 0xfa, 0xff, 0xfe, 0xff, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, + 0xfd, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0xfb, 0xff, 0xfc, 0xff, + 0xfe, 0xff, 0x01, 0x00, 0xfd, 0xff, 0xfe, 0xff, 0x04, 0x00, 0x06, 0x00, 0x04, 0x00, 0xfd, 0xff, + 0x02, 0x00, 0x01, 0x00, 0xff, 0xff, 0x02, 0x00, 0xf9, 0xff, 0x03, 0x00, 0x04, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xfd, 0xff, 0x01, 0x00, 0xfd, 0xff, 0x02, 0x00, 0x0a, 0x00, 0xfa, 0xff, 0x03, 0x00, + 0xfe, 0xff, 0xfd, 0xff, 0xf5, 0xff, 0x04, 0x00, 0x07, 0x00, 0xfc, 0xff, 0x0b, 0x00, 0x05, 0x00, + 0xff, 0xff, 0xfd, 0xff, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0xff, 0xff, 0x0c, 0x00, 0xfc, 0xff, + 0xfc, 0xff, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xfa, 0xff, 0xfe, 0xff, + 0x04, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x01, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, + 0xfe, 0xff, 0x00, 0x00, 0xf8, 0xff, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, 0xf4, 0xff, + 0xfe, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xfa, 0xff, 0xfb, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xfe, 0xff, 0x02, 0x00, 0x06, 0x00, 0x0a, 0x00, 0x01, 0x00, 0xfe, 0xff, 0xf7, 0xff, 0xfc, 0xff, + 0xff, 0xff, 0x00, 0x00, 0xf9, 0xff, 0xfa, 0xff, 0xfc, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfe, 0xff, + 0x02, 0x00, 0xfa, 0xff, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0xfe, 0xff, 0xf8, 0xff, + 0x01, 0x00, 0xff, 0xff, 0xf9, 0xff, 0x03, 0x00, 0x0c, 0x00, 0x01, 0x00, 0xfe, 0xff, 0x03, 0x00, + 0xff, 0xff, 0xfe, 0xff, 0xfc, 0xff, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x04, 0x00, + 0xff, 0xff, 0xff, 0xff, 0x04, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0xfd, 0xff, 0x02, 0x00, + 0xfe, 0xff, 0x0a, 0x00, 0x01, 0x00, 0xff, 0xff, 0x03, 0x00, 0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, + 0x03, 0x00, 0x02, 0x00, 0x06, 0x00, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x02, 0x00, + 0xff, 0xff, 0x06, 0x00, 0xfc, 0xff, 0xfc, 0xff, 0x04, 0x00, 0x00, 0x00, 0xfa, 0xff, 0x06, 0x00, + 0xfe, 0xff, 0xfd, 0xff, 0x09, 0x00, 0x01, 0x00, 0xf8, 0xff, 0xff, 0xff, 0x00, 0x00, 0x07, 0x00, + 0x00, 0x00, 0x03, 0x00, 0xfd, 0xff, 0x00, 0x00, 0xfb, 0xff, 0x03, 0x00, 0xff, 0xff, 0x03, 0x00, + 0x00, 0x00, 0xfe, 0xff, 0xfa, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, + 0xf9, 0xff, 0x07, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf9, 0xff, 0xfd, 0xff, 0x01, 0x00, 0xfc, 0xff, + 0x06, 0x00, 0xf8, 0xff, 0x00, 0x00, 0xf7, 0xff, 0xff, 0xff, 0xfa, 0xff, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0xff, 0x06, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xf9, 0xff, 0xfa, 0xff, 0xf9, 0xff, 0xfe, 0xff, + 0xff, 0xff, 0xfc, 0xff, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x03, 0x00, 0x0a, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xff, 0x05, 0x00, + 0xfd, 0xff, 0xfe, 0xff, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xfd, 0xff, 0x02, 0x00, 0x01, 0x00, + 0xff, 0xff, 0x01, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfa, 0xff, 0xfe, 0xff, + 0x02, 0x00, 0x03, 0x00, 0xfd, 0xff, 0x05, 0x00, 0x00, 0x00, 0xfd, 0xff, 0xf7, 0xff, 0xff, 0xff, + 0xfb, 0xff, 0xf8, 0xff, 0xfe, 0xff, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0xff, 0xff, + 0xf5, 0xff, 0xf8, 0xff, 0xfc, 0xff, 0x02, 0x00, 0x8c, 0xff, 0xff, 0xff, 0x90, 0xff, 0xff, 0xff, + 0x94, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, + 0x18, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x6c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x0c, 0x00, 0x07, 0x00, 0x08, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x24, 0x01, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0xfa, 0xfe, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x44, 0x00, 0x00, 0x00, 0xec, 0xfe, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xb8, 0x19, 0x85, 0x39, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x10, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x62, 0x69, 0x61, 0x73, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x92, 0xff, 0xff, 0xff, 0x14, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x4c, 0x00, 0x00, 0x00, + 0x84, 0xff, 0xff, 0xff, 0x30, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xdd, 0x58, 0xa4, 0x3a, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x18, 0x00, 0x14, 0x00, 0x13, 0x00, 0x0c, 0x00, + 0x08, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x54, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x14, 0x00, + 0x04, 0x00, 0x08, 0x00, 0x0c, 0x00, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x7e, 0x87, 0xb9, 0x39, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x0c, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x11, 0x00, 0x00, 0x00, 0x4f, 0x4e, 0x45, 0x2d, + 0x74, 0x66, 0x6c, 0x69, 0x74, 0x65, 0x32, 0x63, 0x69, 0x72, 0x63, 0x6c, 0x65, 0x00, 0x00, 0x00}; + +const std::vector input_data = { + -39, 0, 107, -69, 99, 27, 80, 52, -5, 29, 38, 23, -123, -46, -40, -89, + -32, -89, -30, 79, 60, 49, 51, 70, -82, 78, 14, 2, -86, -115, -121, 32, + 97, 56, 55, -98, 40, 111, -12, 27, 15, -7, 39, 87, -67, -25, 86, 30, + 17, 25, -73, 108, -93, -78, 41, 106, 117, -74, -79, -31, 0, -98, 56, -81}; + +const std::vector reference_output_data = {2, 3, 10, 2, 3, 4, 1, -2}; + +} // namespace s16_fully_connected + class TestDataS8FullyConnected : public TestDataFullyConnectedBase { public: @@ -135,6 +273,19 @@ class TestDataS8FullyConnected : public TestDataFullyConnectedBase ~TestDataS8FullyConnected() override = default; }; +class TestDataS16FullyConnected : public TestDataFullyConnectedBase +{ +public: + TestDataS16FullyConnected() + { + _input_data = s16_fully_connected::input_data; + _reference_output_data = s16_fully_connected::reference_output_data; + _test_kernel_model_circle = s16_fully_connected::test_kernel_model_circle; + } + + ~TestDataS16FullyConnected() override = default; +}; + } // namespace test_model } // namespace onert_micro diff --git a/onert-micro/onert-micro/src/execute/kernels/FullyConnected.cpp b/onert-micro/onert-micro/src/execute/kernels/FullyConnected.cpp index c86e7146be7..981e93df324 100644 --- a/onert-micro/onert-micro/src/execute/kernels/FullyConnected.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/FullyConnected.cpp @@ -32,9 +32,6 @@ using namespace onert_micro::execute; namespace { -constexpr uint32_t numInput = 3; -constexpr uint32_t numOutput = 1; - constexpr uint32_t inputTensorIdx = 0; constexpr uint32_t weightTensorIdx = 1; constexpr uint32_t biasTensorIdx = 2; @@ -69,9 +66,9 @@ void calculateOpDataFullyConnected(const circle::Tensor *input, const circle::Te const float weight_scale = *weights->quantization()->scale()->begin(); const float output_scale = *output->quantization()->scale()->begin(); - const float input_zero_point = *input->quantization()->zero_point()->begin(); - const float weights_zero_point = *weights->quantization()->zero_point()->begin(); - const float output_zero_point = *output->quantization()->zero_point()->begin(); + const long input_zero_point = *input->quantization()->zero_point()->begin(); + const long weights_zero_point = *weights->quantization()->zero_point()->begin(); + const long output_zero_point = *output->quantization()->zero_point()->begin(); real_multiplier = execute::getQuantizedConvolutionMultipler(input_scale, weight_scale, output_scale); @@ -144,7 +141,7 @@ onert_micro::execute::execute_kernel_CircleFullyConnected(const OMExecuteArgs &e #ifndef DIS_FLOAT case circle::TensorType_FLOAT32: { - FullyConnectedParams params; + FullyConnectedParams params{}; status = calculateActivationRange(options->fused_activation_function(), ¶ms.float_activation_min, ¶ms.float_activation_max); if (status != Ok) @@ -161,7 +158,7 @@ onert_micro::execute::execute_kernel_CircleFullyConnected(const OMExecuteArgs &e #ifndef DIS_QUANT case circle::TensorType_INT8: { - FullyConnectedParams op_params; + FullyConnectedParams op_params{}; calculateOpDataFullyConnected(input, weight, output, options->fused_activation_function(), op_params); @@ -175,7 +172,7 @@ onert_micro::execute::execute_kernel_CircleFullyConnected(const OMExecuteArgs &e break; case circle::TensorType_INT16: { - FullyConnectedParams op_params; + FullyConnectedParams op_params{}; calculateOpDataFullyConnected(input, weight, output, options->fused_activation_function(), op_params); diff --git a/onert-micro/onert-micro/src/execute/kernels/tests/FullyConnected.test.cpp b/onert-micro/onert-micro/src/execute/kernels/tests/FullyConnected.test.cpp index dd1ab900ab2..5085341b761 100644 --- a/onert-micro/onert-micro/src/execute/kernels/tests/FullyConnected.test.cpp +++ b/onert-micro/onert-micro/src/execute/kernels/tests/FullyConnected.test.cpp @@ -41,7 +41,7 @@ TEST_F(FullyConnectedTest, Float_P) EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0)); } -TEST_F(FullyConnectedTest, Float_S8) +TEST_F(FullyConnectedTest, S8_P) { onert_micro::test_model::TestDataS8FullyConnected test_data_kernel; std::vector output_data_vector = @@ -49,6 +49,14 @@ TEST_F(FullyConnectedTest, Float_S8) EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0)); } +TEST_F(FullyConnectedTest, S16_P) +{ + onert_micro::test_model::TestDataS16FullyConnected test_data_kernel; + std::vector output_data_vector = + onert_micro::execute::testing::checkKernel(1, &test_data_kernel); + EXPECT_THAT(output_data_vector, test_data_kernel.get_output_data_by_index(0)); +} + TEST_F(FullyConnectedTest, Wrong_weight_shape_NEG) { onert_micro::test_model::NegTestDataWrongWeightShapeFullyConnectedKernel test_data_kernel; @@ -63,7 +71,12 @@ TEST_F(FullyConnectedTest, Wrong_bias_shape_NEG) EXPECT_DEATH(checkNEGSISOKernel(&test_data_kernel), ""); } -// TODO: add S16 test and more NEG tests +TEST_F(FullyConnectedTest, No_zero_points_NEG) +{ + onert_micro::test_model::NegTestDataNoZeroPointsFullyConnectedKernel test_data_kernel; + + EXPECT_DEATH(checkNEGSISOKernel(&test_data_kernel), ""); +} } // namespace testing } // namespace execute diff --git a/onert-micro/onert-micro/src/import/kernels/FullyConnected.cpp b/onert-micro/onert-micro/src/import/kernels/FullyConnected.cpp index fa668b7517e..3d6f03ba3fa 100644 --- a/onert-micro/onert-micro/src/import/kernels/FullyConnected.cpp +++ b/onert-micro/onert-micro/src/import/kernels/FullyConnected.cpp @@ -104,9 +104,17 @@ onert_micro::import::configure_kernel_CircleFullyConnected(const OMConfigureArgs if (output->quantization()->scale() == nullptr or output->quantization()->scale()->size() != 1) return UnsupportedQuantizationType; + if (output->quantization()->zero_point() == nullptr or + output->quantization()->zero_point()->size() != 1) + return UnsupportedQuantizationType; + if (weight->quantization()->scale() == nullptr or weight->quantization()->scale()->size() != 1) return UnsupportedQuantizationType; + if (weight->quantization()->zero_point() == nullptr or + weight->quantization()->zero_point()->size() != 1) + return UnsupportedQuantizationType; + #endif // DIS_QUANT return status;