Upload dnmetis testtool for NPU inference

This commit is contained in:
alexcheng88
2020-10-23 16:46:10 +08:00
committed by Gitee
parent 183c666c19
commit 40ff8b15a6
16 changed files with 102 additions and 0 deletions
Binary file not shown.
+26
View File
@@ -0,0 +1,26 @@
"""
abstract backend class
"""
# pylint: disable=unused-argument,missing-docstring
class Backend():
def __init__(self):
self.inputs = []
self.outputs = []
def version(self):
raise NotImplementedError("Backend:version")
def name(self):
raise NotImplementedError("Backend:name")
def load(self, args):
raise NotImplementedError("Backend:load")
def predict(self, feed):
raise NotImplementedError("Backend:predict")
def get_predict_time(self):
return 0
+64
View File
@@ -0,0 +1,64 @@
"""
acl backend
"""
import dnmetis_backend as dnmetis_backend
import backend.backend as backend
import numpy as np
import os
import pdb
class AclBackend(backend.Backend):
def __init__(self):
super(AclBackend, self).__init__()
self.ACL=5
self.outputs = ""
self.inputs = ""
self.model_path = ""
self.cfg_path = ""
def version(self):
return "1.0"
def name(self):
return "AclBackend"
def image_format(self):
# By default tensorflow uses NHWC (and the cpu implementation only does NHWC)
return "NHWC"
def load(self, args):
# there is no input/output meta data i the graph so it need to come from config.
if not args.inputs:
raise ValueError("AclBackend needs inputs")
if not args.outputs:
raise ValueError("AclBackend needs outputs")
self.outputs = args.outputs
self.inputs = args.inputs
self.model_path = args.model
self.cfg_path = args.cfg_path
#s.path.join(args.pwd, 'backend_cfg/built-in_config.txt')
dnmetis_backend.backend_setconfig(self.cfg_path)
dnmetis_backend.backend_load(self.ACL,self.model_path,"")
return self
def predict(self, feed):
#fed=feed[self.inputs[0]]
result_list=[]
result = dnmetis_backend.backend_predict(self.ACL,self.model_path,feed)
for _ in range(len(self.outputs)):
#resnet50 tf & caffe
if 'softmax_tensor' in self.outputs[_] or 'prob' in self.outputs[_]:
result_list.append(np.argmax(result[_],1))
# resnet50 tf
if 'ArgMax' in self.outputs[_]:
result_list.append(result[_])
if result_list == []:
# ssd-resnet34 tf
result_list = result
return result_list
def unload(self):
return dnmetis_backend.backend_unload(self.ACL,self.model_path,"")
+2
View File
@@ -0,0 +1,2 @@
aclrtMemMallocPolicy=2
backend_loglevel=3
Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

+10
View File
@@ -0,0 +1,10 @@
ILSVRC2012_val_00000001.JPEG 65
ILSVRC2012_val_00000002.JPEG 970
ILSVRC2012_val_00000003.JPEG 230
ILSVRC2012_val_00000004.JPEG 809
ILSVRC2012_val_00000005.JPEG 516
ILSVRC2012_val_00000006.JPEG 57
ILSVRC2012_val_00000007.JPEG 334
ILSVRC2012_val_00000008.JPEG 415
ILSVRC2012_val_00000009.JPEG 674
ILSVRC2012_val_00000010.JPEG 332