You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

pack.h 4.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef MINDSPORE_LITE_NNACL_PACK_H_
  17. #define MINDSPORE_LITE_NNACL_PACK_H_
  18. #include <stdio.h>
  19. #ifdef ENABLE_NEON
  20. #include <arm_neon.h>
  21. #endif
  22. #include "nnacl/conv_parameter.h"
  23. #include "nnacl/op_base.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. void Im2ColPackUnitFp32(const float *input_data, ConvParameter *conv_param, float *packed_input, int real_cal_num,
  28. int block_index);
  29. void PackHWCToWHC(const float *src, float *dst, int height, int width, int channel);
  30. void Im2ColPackUnitInt8(const int8_t *input_data, int8_t *packed_input, int real_cal_num, int block_index,
  31. int32_t *input_sum, ConvParameter *conv_param);
  32. void Im2ColPackUnitInt8Opt(const int8_t *input_data, int8_t *packed_input, int real_cal_num, int block_index,
  33. int32_t *input_sum, ConvParameter *conv_param);
  34. void PackInputSum16x4PerLayer(const int8_t *src, int32_t *dst, int32_t filter_zp, size_t row4, size_t col16);
  35. void Conv1x1InputPack(const void *src_ptr, void *dst_ptr, ConvParameter *conv_param, int data_size);
  36. void Pack1x1WeightFp32(const float *weight_data, float *packed_weight, ConvParameter *conv_param);
  37. void PackInputSum16x4Int8(const int8_t *input, int32_t *input_sum, int32_t *filter_zp, ConvParameter *conv_param);
  38. void PackInputToC8Int8(const int8_t *input_data, int16_t *packed_input, ConvParameter *conv_param);
  39. void PackWeightKHWToHWKFp32(const void *src, void *dst, int plane, int channel);
  40. void PackWeightInt8(int8_t *weight_data, ConvParameter *conv_param, int8_t *packed_weight, int32_t *weight_sum);
  41. void PackWeightInt8Opt(int8_t *weight_data, ConvParameter *conv_param, int8_t *packed_weight, int32_t *weight_sum);
  42. void PackWeightToC8Int8(const int8_t *origin_weight_data, int16_t *packed_weight_data, ConvParameter *conv_param);
  43. void PackNHWCToNC4HW4Fp32(const void *src, void *dst, int batch, int plane, int channel);
  44. void PackNCHWToNC4HW4Fp32(const void *src, void *dst, int batch, int plane, int channel);
  45. void PackNHWCToNHWC4Fp32(const void *src, void *dst, int batch, int plane, int channel);
  46. void PackNHWCToNCHWFp32(const void *src, void *dst, int batch, int plane, int channel);
  47. void PackNHWCToNCHWInt8(const void *src, void *dst, int batch, int plane, int channel);
  48. void PackNCHWToNHWCFp32(const void *src, void *dst, int batch, int plane, int channel);
  49. void PackNHWC4ToNHWCFp32(const void *src, void *dst, int batch, int plane, int channel);
  50. void PackNC4HW4ToNHWC4Fp32(const void *src, void *dst, int batch, int plane, int channel);
  51. void PackNC4HW4ToNHWCFp32(const void *src, void *dst, int batch, int plane, int channel);
  52. void PackNHWCToC8HWN8Fp32(const void *src, void *dst, int batch, int plane, int channel);
  53. void PackNHWCToNHWC4Int8(const void *src, void *dst, int batch, int plane, int channel);
  54. void PackNHWC4ToNHWCInt8(const void *src, void *dst, int batch, int plane, int channel);
  55. void PackNHWCToNHWC8Int8(const void *src, void *dst, int batch, int plane, int channel);
  56. void PackNHWC8ToNHWCInt8(const void *src, void *dst, int batch, int plane, int channel);
  57. void PackNC4HW4ToNHWCInt8(const void *src, void *dst, int batch, int plane, int channel);
  58. void PackNHWCToC8HWN8Int8(const void *src, void *dst, int batch, int plane, int channel);
  59. void PackNCHWToNHWCInt8(const void *src, void *dst, int batch, int plane, int channel);
  60. void PackDepthwiseInt8Input(const int8_t *src, int16_t *dst, const ConvParameter *conv_param);
  61. void PackDepthwiseInt8Weight(const int8_t *origin_weight, int16_t *packed_weight_, int plane, int channel,
  62. ConvQuantArg *quant_qrg);
  63. void PackDeconvDepthwiseInt8Weight(const int8_t *origin_weight, int16_t *packed_weight_, int plane, int channel,
  64. ConvQuantArg *quant_qrg);
  65. #ifdef ENABLE_ARM
  66. void PreSum4x16Int8Pert(const int8_t *src, int32_t *sum, size_t row4, size_t col16, int32_t filter_zp);
  67. void PreSum4x16Int8Peroc(const int8_t *src, int32_t *sum, int32_t *zp, size_t hw4, size_t ic16, int32_t oc_div,
  68. size_t oc_res, size_t stride);
  69. #endif
  70. #ifdef __cplusplus
  71. }
  72. #endif
  73. #endif // MINDSPORE_LITE_NNACL_PACK_H_