我不太熟悉C/C++开发,如何在python中调用npu
No SDK is available for python as of now… Only C/C++ available
We are waiting for Keras to be able to code neural network code in python, utilizing the NPU, @Frank, says he is doing some work on that
1 Like
@feelbetter 解决方法就是用python去调用NPU工具编译出来的so库,用ctype去调,不是很难调用的
@Electr1 Maybe we will have python version future . But any paltform such TF or kreas can’t call NPU directly . It must convert .
Oh, so we need need existent model to be converted to be able to be used, that’s a bummer
@Electr1 This is impossible unless keras takes the initiative to support this NPU platform
I am not so sure if they would be even interested in supporting our current Platform.
非常感谢,正在学习,是否考虑出一些相关的教程
@feelbetter 这个目前不在计划里,这个ctype安装python的教程来就可以,相当简单的,我这里给你个示例,
def release_model(self, det_type) :
det_release_model = self.detect_so.det_release_model
det_release_model.argtypes = [c_int]
det_release_model(c_int(det_type))
对应的c
det_status_t det_release_model(det_model_type modelType)
{
LOGP("Enter, modeltype:%d", modelType);
int ret = DET_STATUS_OK;
p_det_network_t net = &network[modelType];
if (!net->status) {
LOGW("Model has benn released!");
_SET_STATUS_(ret, DET_STATUS_OK, exit);
}
net->process.model_release(g_dev_type);
if (net->input_ptr) {
free(net->input_ptr);
net->input_ptr = NULL;
}
dlclose(net->handle_id);
net->handle_id = NULL;
net->status = NETWORK_UNINIT;
exit:
LOGP("Leave, modeltype:%d", modelType);
return ret;
}
1 Like