// Autogenerated C header file for Model Runner
#ifndef _JACDAC_SPEC_MODEL_RUNNER_H
#define _JACDAC_SPEC_MODEL_RUNNER_H 1

#define JD_SERVICE_CLASS_MODEL_RUNNER  0x140f9a78

// enum ModelFormat (uint32_t)
#define JD_MODEL_RUNNER_MODEL_FORMAT_TFLITE 0x334c4654
#define JD_MODEL_RUNNER_MODEL_FORMAT_ML4F 0x30470f62
#define JD_MODEL_RUNNER_MODEL_FORMAT_EDGE_IMPULSE_COMPILED 0x30564945

/**
 * Argument: model_size B uint32_t. Open pipe for streaming in the model. The size of the model has to be declared upfront.
 * The model is streamed over regular pipe data packets.
 * The format supported by this instance of the service is specified in `format` register.
 * When the pipe is closed, the model is written all into flash, and the device running the service may reset.
 */
#define JD_MODEL_RUNNER_CMD_SET_MODEL 0x80

/**
 * Report: Argument: model_port pipe_port (uint16_t)
 */

/**
 * Argument: outputs pipe (bytes). Open channel that can be used to manually invoke the model. When enough data is sent over the `inputs` pipe, the model is invoked,
 * and results are send over the `outputs` pipe.
 */
#define JD_MODEL_RUNNER_CMD_PREDICT 0x81

/**
 * Report: Argument: inputs pipe_port (uint16_t)
 */

/**
 * Read-write uint16_t. When register contains `N > 0`, run the model automatically every time new `N` samples are collected.
 * Model may be run less often if it takes longer to run than `N * sampling_interval`.
 * The `outputs` register will stream its value after each run.
 * This register is not stored in flash.
 */
#define JD_MODEL_RUNNER_REG_AUTO_INVOKE_EVERY 0x80

/**
 * Read-only. Results of last model invocation as `float32` array.
 */
#define JD_MODEL_RUNNER_REG_OUTPUTS JD_REG_READING
typedef struct jd_model_runner_outputs {
    float output[0];  // f32
} jd_model_runner_outputs_t;


/**
 * Read-only. The shape of the input tensor.
 */
#define JD_MODEL_RUNNER_REG_INPUT_SHAPE 0x180
typedef struct jd_model_runner_input_shape {
    uint16_t dimension[0];
} jd_model_runner_input_shape_t;


/**
 * Read-only. The shape of the output tensor.
 */
#define JD_MODEL_RUNNER_REG_OUTPUT_SHAPE 0x181
typedef struct jd_model_runner_output_shape {
    uint16_t dimension[0];
} jd_model_runner_output_shape_t;


/**
 * Read-only μs uint32_t. The time consumed in last model execution.
 */
#define JD_MODEL_RUNNER_REG_LAST_RUN_TIME 0x182

/**
 * Read-only B uint32_t. Number of RAM bytes allocated for model execution.
 */
#define JD_MODEL_RUNNER_REG_ALLOCATED_ARENA_SIZE 0x183

/**
 * Read-only B uint32_t. The size of the model in bytes.
 */
#define JD_MODEL_RUNNER_REG_MODEL_SIZE 0x184

/**
 * Read-only string (bytes). Textual description of last error when running or loading model (if any).
 */
#define JD_MODEL_RUNNER_REG_LAST_ERROR 0x185

/**
 * Constant ModelFormat (uint32_t). The type of ML models supported by this service.
 * `TFLite` is flatbuffer `.tflite` file.
 * `ML4F` is compiled machine code model for Cortex-M4F.
 * The format is typically present as first or second little endian word of model file.
 */
#define JD_MODEL_RUNNER_REG_FORMAT 0x186

/**
 * Constant uint32_t. A version number for the format.
 */
#define JD_MODEL_RUNNER_REG_FORMAT_VERSION 0x187

/**
 * Constant bool (uint8_t). If present and true this service can run models independently of other
 * instances of this service on the device.
 */
#define JD_MODEL_RUNNER_REG_PARALLEL 0x188

#endif
