|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +/*! |
| 21 | + * \file src/relay/backend/contrib/cmsisnn/buffer_size.h |
| 22 | + * \brief CMSIS-NN Buffer Size calculation functions |
| 23 | + */ |
| 24 | + |
| 25 | +#ifndef TVM_RELAY_BACKEND_CONTRIB_CMSISNN_BUFFER_SIZE_H_ |
| 26 | +#define TVM_RELAY_BACKEND_CONTRIB_CMSISNN_BUFFER_SIZE_H_ |
| 27 | + |
| 28 | +#include <tvm/ir/transform.h> |
| 29 | + |
| 30 | +#include "compiler_attrs.h" |
| 31 | + |
| 32 | +namespace tvm { |
| 33 | +namespace relay { |
| 34 | +namespace contrib { |
| 35 | +namespace cmsisnn { |
| 36 | + |
| 37 | +/*! |
| 38 | + * \brief Calculates the appropriate buffer size for CMSIS-NN Convolutions |
| 39 | + * See: |
| 40 | + * https://github.com/ARM-software/CMSIS_5/blob/8c60448c0e1e50e426180b26db9bc31ddf774361/CMSIS/NN/Source/ConvolutionFunctions/arm_convolve_wrapper_s8.c#L108-L127 |
| 41 | + * |
| 42 | + * \param flags - CMSIS-NN feature flags |
| 43 | + * \param padding_w - Width padding |
| 44 | + * \param padding_h - Height padding |
| 45 | + * \param input_n - Input batch size |
| 46 | + * \param input_h - Input height |
| 47 | + * \param input_c - Input channels |
| 48 | + * \param output_h - Output height |
| 49 | + * \param output_w - Output width |
| 50 | + * \param stride_w - Stride width |
| 51 | + * \param stride_h - Stride height |
| 52 | + * \param filter_w - Filter width |
| 53 | + * \param filter_h - Filter height |
| 54 | + * |
| 55 | + * \return Size of buffer to allocate for convolution |
| 56 | + */ |
| 57 | +int Conv2dBufferSize(CMSISNNFlags flags, int32_t padding_w, int32_t padding_h, int32_t input_n, |
| 58 | + int32_t input_h, int32_t input_c, int32_t output_h, int32_t output_w, |
| 59 | + int32_t stride_w, int32_t stride_h, int32_t filter_w, int32_t filter_h); |
| 60 | + |
| 61 | +} // namespace cmsisnn |
| 62 | +} // namespace contrib |
| 63 | +} // namespace relay |
| 64 | +} // namespace tvm |
| 65 | + |
| 66 | +#endif // TVM_RELAY_BACKEND_CONTRIB_CMSISNN_BUFFER_SIZE_H_ |
0 commit comments