rt_ai_common.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-04-01 liqiwen the first version
  9. */
  10. #include <rt_ai_common.h>
  11. #include <rt_ai_log.h>
  12. void rt_ai_allocate_buffer(rt_ai_t ai, rt_ai_buffer_t *buf)
  13. {
  14. int addr = 0;
  15. int i;
  16. if (ai->mem_flag & ALLOC_WORK_BUFFER_FLAG)
  17. {
  18. AI_LOG_I("allocate work offet addr: %d\n", addr);
  19. ai->workbuffer = buf + addr;
  20. addr += ai->info.work_buffer_size;
  21. }
  22. if (ai->mem_flag & ALLOC_INPUT_BUFFER_FLAG)
  23. {
  24. for (i = 0; i < ai->info.input_n; i++)
  25. {
  26. AI_LOG_I("allocate in %d offet addr: %d\n", i, addr);
  27. ai->input[i] = buf + addr;
  28. addr += ai->info.input_n_stack[i];
  29. }
  30. }
  31. if (ai->mem_flag & ALLOC_OUTPUT_BUFFER_FLAG)
  32. {
  33. for (i = 0; i < ai->info.output_n; i++)
  34. {
  35. AI_LOG_I("allocate out %d offet addr: %d\n", i, addr);
  36. ai->output[i] = buf + addr;
  37. addr += ai->info.output_n_stack[i];
  38. }
  39. }
  40. }