0

我正在尝试在我的 uVision 项目中构建由 STM32CubeMx 创建的网络,并为了初始化我编写的网络模型:

    ai_error ai_err;
    ai_i32 nbatch;
    uint32_t timestamp;
    float y_val;
    int buf_len = 0;

    // Chunk of memory used to hold intermediate values for neural network
    AI_ALIGNED(4) ai_u8 activations[AI_NETWORK_DATA_ACTIVATIONS_SIZE];

    // Buffers used to store input and output tensors
    AI_ALIGNED(4) ai_i8 in_data[AI_NETWORK_IN_1_SIZE_BYTES];
    AI_ALIGNED(4) ai_i8 out_data[AI_NETWORK_OUT_1_SIZE_BYTES];

// 指向我们模型的指针 ai_handle net_model = AI_HANDLE_NULL;

    // Initialize wrapper structs that hold pointers to data and info about the
    // data (tensor height, width, channels)
    ai_buffer ai_input[AI_NETWORK_IN_NUM] = AI_NETWORK_IN;
    ai_buffer ai_output[AI_NETWORK_OUT_NUM] = AI_NETWORK_OUT;


    // Set working memory and get weights/biases from model
    ai_network_params ai_params = {
        AI_NETWORK_DATA_WEIGHTS(ai_network_data_weights_get()),
        AI_NETWORK_DATA_ACTIVATIONS(activations)
    };

但是我在 AI_NETWORK_DATA_WEIGHTS 上遇到了一些错误,上面说

字段指示符“格式”不引用“联合 ai_network_params_:::”类型中的任何字段(匿名位于 ../Middlewares/ST/AI/Inc\ai_platform.h:607:3)

字段指示符“n_batched”不引用“联合 ai_network_params_:::”类型中的任何字段(匿名位于 ../Middlewares/ST/AI/Inc\ai_platform.h:607:3)

字段指示符“height”不引用“union ai_network_params_:::”类型中的任何字段(匿名位于 ../Middlewares/ST/AI/Inc\ai_platform.h:607:3)

字段指示符“宽度”不引用“联合 ai_network_params_:::”类型中的任何字段(匿名于 ../Middlewares/ST/AI/Inc\ai_platform.h:607:3)

字段指示符“通道”不引用类型“联合 ai_network_params_:::”中的任何字段(匿名位于 ../Middlewares/ST/AI/Inc\ai_platform.h:607:3)

字段指示符“数据”不引用“联合 ai_network_params_:::”类型中的任何字段(匿名位于 ../Middlewares/ST/AI/Inc\ai_platform.h:607:3)

字段指示符“meta_info”不引用“联合 ai_network_params_:::”类型中的任何字段(匿名位于 ../Middlewares/ST/AI/Inc\ai_platform.h:607:3)

AI_NETWORK_DATA_WEIGHTS定义为

#define AI_NETWORK_DATA_WEIGHTS(ptr_)  \
  AI_BUFFER_OBJ_INIT( \
    AI_BUFFER_FORMAT_U8|AI_BUFFER_FMT_FLAG_CONST, \
    AI_NETWORK_DATA_WEIGHTS_COUNT, 1, AI_NETWORK_DATA_WEIGHTS_SIZE, 1, \
    AI_HANDLE_PTR(ptr_) )

数据结构ai_network_params_定义为

typedef struct ai_network_params_ {
  AI_NETWORK_PARAMS_FIELDS_DECLARE
} ai_network_params;

下一步AI_NETWORK_PARAMS_FIELDS_DECLARE

#define AI_NETWORK_PARAMS_FIELDS_DECLARE \
union { \
  struct { \
    ai_buffer         params;         /*! info about params buffer(required!) */ \
    ai_buffer         activations;    /*! info about activations buffer (required!) */ \
  }; \
  struct { \
    AI_NETWORK_BUFFERS_FIELD_DECLARE \
  }; \
};

最后ai_buffer

typedef struct ai_buffer_ {
  ai_buffer_format        format;     /*!< buffer format */
  ai_u16                  n_batches;  /*!< number of batches in the buffer */
  ai_u16                  height;     /*!< buffer height dimension */
  ai_u16                  width;      /*!< buffer width dimension */
  ai_u32                  channels;   /*!< buffer number of channels */
  ai_handle               data;       /*!< pointer to buffer data */
  ai_buffer_meta_info*    meta_info;  /*!< pointer to buffer metadata info */
} ai_buffer;

我认为该功能存在一些问题ai_network_data_weights_get()

ai_handle ai_network_data_weights_get(void)
{
  static const ai_u8* const s_network_weights_map[1 + 2] = {
    AI_PTR(AI_MAGIC_MARKER),
    AI_PTR(s_network_weights_array_u64),
    AI_PTR(AI_MAGIC_MARKER)
  };

  return AI_HANDLE_PTR(s_network_weights_map);

}

调试选项如图所示: 调试

我怎样才能摆脱这些错误?

谢谢

4

0 回答 0