io.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /* auto generate by HHB_VERSION "2.0.21" */
  20. #ifndef HHB_IO_H_
  21. #define HHB_IO_H_
  22. #include <math.h>
  23. #include <stdint.h>
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #define MAX_FILE_LINE 50001
  28. #define MAX_INPUT_NUMBER 4
  29. #define MAX_FILENAME_LEN 1280
  30. enum file_type { FILE_PNG, FILE_JPEG, FILE_TENSOR, FILE_TXT, FILE_BIN };
  31. /* Utils to process image data*/
  32. enum file_type get_file_type(const char* filename);
  33. void save_data_to_file(const char* filename, float* data, uint32_t size);
  34. void save_uint8_to_file(const char* filename, uint8_t* data, uint32_t size);
  35. void save_uint8_to_binary(const char* filename, uint8_t* data, uint32_t size);
  36. char* get_binary_from_file(const char* filename, int* size);
  37. int fill_buffer_from_file(const char* filename, char *buffer);
  38. char** read_string_from_file(const char* filename, int* len);
  39. uint32_t shape2string(uint32_t* shape, uint32_t dim_num, char* buf, uint32_t buf_sz);
  40. #endif // HHB_IO_H_