utils.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * SPDX-FileCopyrightText: Copyright 2022 Arm Limited and/or its affiliates <open-source-office@arm.com>
  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. #pragma once
  19. #include <stdint.h>
  20. static inline const int32_t *get_bias_address(const int32_t *bias, int32_t size)
  21. {
  22. const int32_t *return_bias = NULL;
  23. for (int i = 0; i < size; i++)
  24. {
  25. if (bias[i] != 0)
  26. {
  27. return_bias = bias;
  28. break;
  29. }
  30. }
  31. return return_bias;
  32. }
  33. static inline const int64_t *get_bias_s64_address(const int64_t *bias, int32_t size)
  34. {
  35. const int64_t *return_bias = NULL;
  36. for (int i = 0; i < size; i++)
  37. {
  38. if (bias[i] != 0)
  39. {
  40. return_bias = bias;
  41. break;
  42. }
  43. }
  44. return return_bias;
  45. }