#ifndef SW_VEC_IREE_SAMPLES_UTIL_UTIL_H_
#define SW_VEC_IREE_SAMPLES_UTIL_UTIL_H_

#include "iree/base/api.h"
#include "iree/hal/api.h"
#include "iree/modules/hal/module.h"
#include "iree/vm/api.h"
#include "iree/vm/bytecode_module.h"

#define MAX_MODEL_INPUT_NUM 2
#define MAX_MODEL_INPUT_DIM 4
#define MAX_MODEL_OUTPUTS 12
#define MAX_ENTRY_FUNC_NAME 20

typedef struct {
  int num_input;
  int num_input_dim[MAX_MODEL_INPUT_NUM];
  iree_hal_dim_t input_shape[MAX_MODEL_INPUT_NUM][MAX_MODEL_INPUT_DIM];
  int input_length[MAX_MODEL_INPUT_NUM];
  int input_size_bytes[MAX_MODEL_INPUT_NUM];
  int num_output;
  int output_length[MAX_MODEL_OUTPUTS];
  int output_size_bytes;
  enum iree_hal_element_types_t hal_element_type;
  char entry_func[MAX_ENTRY_FUNC_NAME];
  char model_name[];
} MlModel;

// Allocate the input buffer w.r.t the model config.
// The buffer must be released by the external caller.
static inline iree_status_t alloc_input_buffer(const MlModel *model,
                                               void **buffer) {
  iree_status_t result = iree_ok_status();
  for (int i = 0; i < model->num_input; ++i) {
    if (iree_status_is_ok(result)) {
      buffer[i] =
          iree_aligned_alloc(
              sizeof(uint32_t),
              model->input_size_bytes[i] * model->input_length[i]);
      if (buffer[i] == NULL) {
        result = iree_make_status(IREE_STATUS_RESOURCE_EXHAUSTED);
      }
    }
  }
  return result;
}

#endif  // SW_VEC_IREE_SAMPLES_UTIL_UTIL_H_
