1 /* 2 * Copyright (C) 2020-2021 Arm Limited or its affiliates. All rights reserved. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Licensed under the Apache License, Version 2.0 (the License); you may 7 * not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT 14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /* ---------------------------------------------------------------------- 20 * Project: CMSIS NN Library 21 * Title: arm_nn_types.h 22 * Description: Public header file to contain the CMSIS-NN structs for the 23 * TensorFlowLite micro compliant functions 24 * 25 * $Date: 19. March 2021 26 * $Revision: V.2.0.0 27 * 28 * Target Processor: Cortex-M cores 29 * -------------------------------------------------------------------- */ 30 31 #ifndef _ARM_NN_TYPES_H 32 #define _ARM_NN_TYPES_H 33 34 #include <stdint.h> 35 36 /** CMSIS-NN object to contain the width and height of a tile */ 37 typedef struct 38 { 39 int32_t w; /**< Width */ 40 int32_t h; /**< Height */ 41 } cmsis_nn_tile; 42 43 /** CMSIS-NN object used for the function context. */ 44 typedef struct 45 { 46 void *buf; /**< Pointer to a buffer needed for the optimization */ 47 int32_t size; /**< Buffer size */ 48 } cmsis_nn_context; 49 50 /** CMSIS-NN object to contain the dimensions of the tensors */ 51 typedef struct 52 { 53 int32_t n; /**< Generic dimension to contain either the batch size or output channels. 54 Please refer to the function documentation for more information */ 55 int32_t h; /**< Height */ 56 int32_t w; /**< Width */ 57 int32_t c; /**< Input channels */ 58 } cmsis_nn_dims; 59 60 /** CMSIS-NN object for the per-channel quantization parameters */ 61 typedef struct 62 { 63 int32_t *multiplier; /**< Multiplier values */ 64 int32_t *shift; /**< Shift values */ 65 } cmsis_nn_per_channel_quant_params; 66 67 /** CMSIS-NN object for the per-tensor quantization parameters */ 68 typedef struct 69 { 70 int32_t multiplier; /**< Multiplier value */ 71 int32_t shift; /**< Shift value */ 72 } cmsis_nn_per_tensor_quant_params; 73 74 /** CMSIS-NN object for the quantized Relu activation */ 75 typedef struct 76 { 77 int32_t min; /**< Min value used to clamp the result */ 78 int32_t max; /**< Max value used to clamp the result */ 79 } cmsis_nn_activation; 80 81 /** CMSIS-NN object for the convolution layer parameters */ 82 typedef struct 83 { 84 int32_t input_offset; /**< Zero value for the input tensor */ 85 int32_t output_offset; /**< Zero value for the output tensor */ 86 cmsis_nn_tile stride; 87 cmsis_nn_tile padding; 88 cmsis_nn_tile dilation; 89 cmsis_nn_activation activation; 90 } cmsis_nn_conv_params; 91 92 /** CMSIS-NN object for Depthwise convolution layer parameters */ 93 typedef struct 94 { 95 int32_t input_offset; /**< Zero value for the input tensor */ 96 int32_t output_offset; /**< Zero value for the output tensor */ 97 int32_t ch_mult; /**< Channel Multiplier. ch_mult * in_ch = out_ch */ 98 cmsis_nn_tile stride; 99 cmsis_nn_tile padding; 100 cmsis_nn_tile dilation; 101 cmsis_nn_activation activation; 102 } cmsis_nn_dw_conv_params; 103 /** CMSIS-NN object for pooling layer parameters */ 104 typedef struct 105 { 106 cmsis_nn_tile stride; 107 cmsis_nn_tile padding; 108 cmsis_nn_activation activation; 109 } cmsis_nn_pool_params; 110 111 /** CMSIS-NN object for Fully Connected layer parameters */ 112 typedef struct 113 { 114 int32_t input_offset; /**< Zero value for the input tensor */ 115 int32_t filter_offset; /**< Zero value for the filter tensor. Not used */ 116 int32_t output_offset; /**< Zero value for the output tensor */ 117 cmsis_nn_activation activation; 118 } cmsis_nn_fc_params; 119 120 /** CMSIS-NN object for SVDF layer parameters */ 121 typedef struct 122 { 123 int32_t rank; 124 int32_t input_offset; /**< Zero value for the input tensor */ 125 int32_t output_offset; /**< Zero value for the output tensor */ 126 cmsis_nn_activation input_activation; 127 cmsis_nn_activation output_activation; 128 } cmsis_nn_svdf_params; 129 130 #endif // _ARM_NN_TYPES_H 131