更新时间:2021-03-18 GMT+08:00
AINeuralNetworkBuffer
NN通用Buffer定义。该类在ai_tensor.h中定义。
class AINeuralNetworkBuffer : public AISimpleTensor { public: AINeuralNetworkBuffer() { data_type_ = 0; number_ = 1; channel_ = 1; height_ = 1; width_ = 1; name_ = ""; }; ~AINeuralNetworkBuffer() {}; /* * @brief 获取类型名称 */ const char* const GetTypeName(); /* @brief 获取size字节大小 */ uint32_t ByteSizeLong(); /* @brief 初始化 @param [in] tensor_desc tensor描述 */ bool Init(const AITensorDescription &tensor_desc); #if defined( __ANDROID__) || defined(ANDROID) /* * @brief 序列化到buffer,用于数据跨进程交互 * @param [in] buffer 序列化输出的内存区域地址,由调用方分配 * @param [in] size 输出内存区域的大小 * @return SUCCESS: 成功 * FAILED: 失败,如果该Tensor不支持跨进程,则不需要实现此接口,直接返回失败 */ AIStatus SerializeTo(void* buffer, uint32_t size_); /* * @brief 从buffer反序列化回tensor,用于数据跨进程交互 * @param [in] buffer 输入的内存区域地址 * @param [in] size 输入内存区域的大小 * @return SUCCESS: 成功 * FAILED: 失败,如果该Tensor不支持跨进程,则不需要实现此接口,直接返回失败 */ AIStatus DeserializeFrom(const void* buffer, uint32_t size_); #endif /* * @brief 获取描述信息 */ static AITensorDescription GetDescription( const std::string &size = "0",const std::string &data_type="0", const std::string &number="0", const std::string &channel="0", const std::string &height="0", const std::string &width="0"); /* @brief 创建tensor */ static std::shared_ptr<IAITensor> CreateTensor(const AITensorDescription& tensor_desc); /* @brief 获取number数量 */ int32_t GetNumber(); /* @brief 设置number */ void SetNumber(int32_t number); /* @brief 获取channel数量 */ int32_t GetChannel(); /* @brief 设置channel */ void SetChannel(int32_t channel); /* @brief 获取height */ int32_t GetHeight(); /* @brief 设置height */ void SetHeight(int32_t height); /* @brief 获取width */ int32_t GetWidth(); /* @brief 设置width */ void SetWidth(int32_t width); /* @brief 获取数据类型 */ int32_t GetData_type(); /* @brief 设置数据类型 */ void SetData_type(int32_t data_type); /* @brief 获取数据类型 */ const std::string& GetName() const; /* @brief 设置数据类型 */ void SetName(const std::string& value); private: int32_t data_type_; int32_t number_; int32_t channel_; int32_t height_; int32_t width_; std::string name_; };
父主题: 其他用于编译依赖的接口