-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support ncnn benchmark * Import ncnn and available_benchmark to the init scope
- Loading branch information
1 parent
cf4455e
commit 22448f2
Showing
8 changed files
with
184 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
from edgebenchmark.tflite_benchmark import TFLiteBenchmark | ||
from edgebenchmark.ncnn_benchmark import NcnnBenchmark | ||
from edgebenchmark.settings import available_benchmarks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright 2021 Bisonai Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
from edgebenchmark.settings import settings | ||
from edgebenchmark.settings import available_benchmarks | ||
from edgebenchmark.ncnn_benchmark_20210124 import NcnnBenchmark_20210124 | ||
|
||
|
||
def NcnnBenchmark(version: int): | ||
""" | ||
""" | ||
assert version in settings._NCNN_VERSIONS | ||
|
||
if version in ("20210124"): | ||
b = NcnnBenchmark_20210124 | ||
else: | ||
raise ValueError(f"Invalid Ncnn version number. Choose one of {settings._NCNN_VERSIONS}") | ||
|
||
benchmark = b(version) | ||
benchmark.benchmark_type = available_benchmarks.ncnn_basic | ||
return benchmark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Copyright 2021 Bisonai Authors. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ============================================================================== | ||
from edgebenchmark.edgebenchmark import EdgeBenchmark | ||
|
||
|
||
class NcnnBenchmark_20210124(EdgeBenchmark): | ||
@staticmethod | ||
def default(): | ||
return { | ||
"loop_count": 4, | ||
"num_threads": -1, | ||
"powersave": 0, | ||
"gpu_device": -1, | ||
"cooling_down": 1, | ||
|
||
"height": 227, | ||
"width": 227, | ||
"channels": 3, | ||
} | ||
|
||
@staticmethod | ||
def parameters(): | ||
return { | ||
"loop_count": int, | ||
"num_threads": int, | ||
"powersave": int, | ||
"gpu_device": int, | ||
"cooling_down": int, | ||
"height": int, | ||
"width": int, | ||
"channels": int, | ||
} | ||
|
||
@property | ||
def loop_count(self): | ||
""" | ||
""" | ||
return self.get_parameter("loop_count") | ||
|
||
@loop_count.setter | ||
def loop_count(self, value: int): | ||
if not isinstance(value, int): | ||
raise ValueError("loop_count must be type of int") | ||
self.set_parameter("loop_count", value) | ||
|
||
@property | ||
def num_threads(self): | ||
""" | ||
-1=max_cpu_count | ||
""" | ||
return self.get_parameter("num_threads") | ||
|
||
@num_threads.setter | ||
def num_threads(self, value: int): | ||
if not isinstance(value, int): | ||
raise ValueError("num_threads must be type of int") | ||
self.set_parameter("num_threads", value) | ||
|
||
@property | ||
def powersave(self): | ||
""" | ||
0=all cores | ||
1=little cores only | ||
2=big cores only | ||
""" | ||
return self.get_parameter("powersave") | ||
|
||
@powersave.setter | ||
def powersave(self, value: int): | ||
if not isinstance(value, int): | ||
raise ValueError("powersave must be type of int") | ||
self.set_parameter("powersave", value) | ||
|
||
@property | ||
def gpu_device(self): | ||
""" | ||
-1=cpu-only | ||
0=gpu0 | ||
1=gpu1 | ||
... | ||
""" | ||
return self.get_parameter("gpu_device") | ||
|
||
@gpu_device.setter | ||
def gpu_device(self, value: int): | ||
if not isinstance(value, int): | ||
raise ValueError("gpu_device must be type of int") | ||
self.set_parameter("gpu_device", value) | ||
|
||
@property | ||
def cooling_down(self): | ||
""" | ||
0=disable | ||
1=enable | ||
""" | ||
return self.get_parameter("cooling_down") | ||
|
||
@cooling_down.setter | ||
def cooling_down(self, value: int): | ||
if not isinstance(value, int): | ||
raise ValueError("cooling_down must be type of int") | ||
self.set_parameter("cooling_down", value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters