[MSLITE][DEVELOP] fix bug of npu frequency

This commit is contained in:
yangruoqi713 2021-07-05 14:49:28 +08:00
parent 5bac99a7e8
commit 7bef95e7f6
4 changed files with 6 additions and 6 deletions

View File

@ -69,7 +69,7 @@ NPUDelegate::~NPUDelegate() {
}
int NPUDelegate::Init() {
npu_manager_ = new (std::nothrow) NPUManager();
npu_manager_ = new (std::nothrow) NPUManager(frequency_);
if (npu_manager_ == nullptr) {
MS_LOG(ERROR) << "New npu manager failed.";
return RET_ERROR;

View File

@ -48,7 +48,7 @@ struct SubGraphModel {
class NPUManager {
public:
NPUManager() = default;
explicit NPUManager(int frequency) : frequency_(frequency) {}
~NPUManager() { Reset(); }
@ -70,6 +70,8 @@ class NPUManager {
int LoadModel(const std::shared_ptr<hiai::AiModelMngerClient> &client,
std::vector<std::shared_ptr<hiai::AiModelDescription>> desc_list);
int GetFrequency() { return frequency_; }
private:
bool IsKirinChip();
@ -87,6 +89,7 @@ class NPUManager {
bool is_support_ = false;
std::unordered_map<std::string, std::shared_ptr<SubGraphModel>> models_;
std::vector<std::shared_ptr<hiai::AiModelMngerClient>> clients_;
int frequency_ = 0;
};
} // namespace mindspore

View File

@ -170,7 +170,6 @@ int NPUSubGraph::BuildNPUInputOp() {
}
bool is_weight_tensor = true;
// todo cpu in_ops can't be found
auto pre_ops = FindPreOps(op);
for (auto pre_op : pre_ops) {
if (find(pre_op->outputs().begin(), pre_op->outputs().end(), in_tensor) != pre_op->outputs().end()) {
@ -276,8 +275,7 @@ int NPUSubGraph::Init() {
}
MS_ASSERT(npu_manager_ != nullptr);
// todo y00520784, get frequency
npu_manager_->AddModel(model_buffer_data, GetOMModelName(), 3);
npu_manager_->AddModel(model_buffer_data, GetOMModelName(), npu_manager_->GetFrequency());
executor_ = new (std::nothrow) NPUExecutor(GetOMModelName(), npu_manager_);

View File

@ -57,7 +57,6 @@ class NPUPassUtils {
static int MaskDataNHWC2NCHW(int mask);
};
// todo y00520784 : refactor the code of transform op
class RuntimePass {
public:
RuntimePass(std::vector<NPUOp *> *ops, std::vector<tensor::MSTensor *> *tensors)