You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
5.6 KiB

/**
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2020-2020. All rights reserved.
*
* @file HLAIModelManagerService.h
*
*
*/
#ifndef __AI_MODEL_MANGER_SERVICE_H__
#define __AI_MODEL_MANGER_SERVICE_H__
#include <string>
#include <vector>
#include <map>
#include <mutex>
#include "HLAIModelManagerType.h"
namespace hlai {
class AiModelMngerClientImpl;
class AiModelMngerClient;
class AiModelBuilderImpl;
class AiModelBuilder {
public:
explicit AiModelBuilder(std::shared_ptr<AiModelMngerClient> client = nullptr);
virtual ~AiModelBuilder();
/*
* @brief OM线proto
* @param [in] path,
* @return MemBuffer * proto
* @return nullptr
*/
MemBuffer* ReadBinaryProto(const std::string path);
/*
* @brief OM线proto
* @param [in] data, OM线
* @param [in] size, OM线
* @return MemBuffer * proto
* @return nullptr
*/
MemBuffer* ReadBinaryProto(void* data, uint32_t size);
/*
* @brief OM线bufferMemBuffer
* @param [in] data,
* @param [in] size,
* @return MemBuffer * proto
* @return nullptr
*/
MemBuffer* InputMemBufferCreate(void *data, uint32_t size);
/*
* @brief OM线MemBuffer
* @param [in] path
* @return MemBuffer * MemBuffer
* @return nullptr
*/
MemBuffer* InputMemBufferCreate(const std::string path);
/*
* @brief 线MemBuffer
* @param [in] framework
* @param [in] pinputMemBuffer OM线buffer
* @return MemBuffer * MemBuffer
* @return nullptr
*/
MemBuffer* OutputMemBufferCreate(const int32_t framework, const std::vector<MemBuffer *> &pinputMemBuffer);
/*
* @brief MemBufferMemBuffer
* @param [in] membuf, MemBuffer
* @return void
*/
void MemBufferDestroy(MemBuffer *membuf);
/*
* @brief buffer
* @param [in] membuf, 线
* @param [in] pbuildSize, 线
* @param [in] pbuildPath, 线
* @return AIStatus::AI_SUCCESS
* @return Others
*/
AIStatus MemBufferExportFile(MemBuffer *membuf, const uint32_t pbuildSize, const std::string pbuildPath);
private:
std::shared_ptr<AiModelBuilderImpl> builderImpl_;
};
class AiModelMngerClient {
public:
AiModelMngerClient();
virtual ~AiModelMngerClient();
/*
* @brief
* @param [in] listener , nullptr,
* @return AIStatus::AI_SUCCESS
* @return Others
*/
AIStatus Init(std::shared_ptr<AiModelManagerClientListener> listener);
/*
* @brief
* @param [in] pmodelDesc
* @param [in] piStamp
* @return AIStatus::AI_SUCCESS
* @return AIStatus::AI_INVALID_API NPU
* @return Others
*/
AIStatus Load(std::vector<std::shared_ptr<AiModelDescription>> &pmodelDesc);
/*
* @brief ,
* @param [in] context, , model_name
* @param [in] pinputTensor, tensor
* @param [in] poutputTensor, tensor
* @param [in] timeout,
* @param [in] piStamp
* @return AIStatus::AI_SUCCESS
* @return Others
*/
AIStatus Process(AiContext &context, std::vector<std::shared_ptr<AiTensor>> &pinputTensor,
std::vector<std::shared_ptr<AiTensor>> &poutputTensor, uint32_t timeout, int32_t &piStamp);
/*
* @brief
* @param [in] pmodelDesc,
* @param [out] pisModelCompatibility,
* @return AIStatus::AI_SUCCESS
* @return Others
*/
AIStatus CheckModelCompatibility(AiModelDescription &pmodelDesc, bool &pisModelCompatibility);
/*
* @brief tensor
* @param [in] pmodelName,
* @param [out] pinputTensor , tensor
* @param [out] poutputTensor , tensor
* @return AIStatus::AI_SUCCESS
* @return Others
*/
AIStatus GetModelIOTensorDim(const std::string& pmodelName, std::vector<TensorDimension>& pinputTensor,
std::vector<TensorDimension>& poutputTensor);
/*
* @brief DDK
* @return char * DDK
* @return nullptr
*/
const char* GetVersion();
/*
* @brief
* @return AIStatus::AI_SUCCESS
* @return Others
*/
AIStatus UnLoadModel();
private:
friend class AiModelBuilderImpl;
std::shared_ptr<AiModelMngerClientImpl> clientImpl_;
};
} // end namespace hlai
#endif