forked from intel/ai-reference-models
-
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.
Checkout remaining changes from develop
- Loading branch information
Showing
88 changed files
with
1,308 additions
and
641 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
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
17 changes: 17 additions & 0 deletions
17
benchmarks/image_recognition/tensorflow/mobilenet_v1/inference/bfloat16/__init__.py
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,17 @@ | ||
# | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2020 Intel Corporation | ||
# | ||
# 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. | ||
# |
6 changes: 6 additions & 0 deletions
6
benchmarks/image_recognition/tensorflow/mobilenet_v1/inference/bfloat16/config.json
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,6 @@ | ||
{ | ||
"optimization_parameters": { | ||
"KMP_AFFINITY": "granularity=fine,verbose,compact,1,0", | ||
"KMP_BLOCKTIME": 1 | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
benchmarks/image_recognition/tensorflow/mobilenet_v1/inference/bfloat16/model_init.py
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,104 @@ | ||
# | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2020 Intel Corporation | ||
# | ||
# 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. | ||
# | ||
|
||
import argparse | ||
import os | ||
from common.base_model_init import BaseModelInitializer | ||
from common.base_model_init import set_env_var | ||
|
||
|
||
class ModelInitializer(BaseModelInitializer): | ||
""" Model initializer for MobileNet V1 BFloat16 inference """ | ||
|
||
def __init__(self, args, custom_args=[], platform_util=None): | ||
super(ModelInitializer, self).__init__(args, custom_args, platform_util) | ||
|
||
# use default batch size if -1 | ||
if self.args.batch_size == -1: | ||
self.args.batch_size = 128 | ||
|
||
# Set KMP env vars, if they haven't already been set | ||
config_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.json") | ||
self.set_kmp_vars(config_file_path) | ||
|
||
# set num_inter_threads and num_intra_threads (override inter threads to 2) | ||
self.set_num_inter_intra_threads(num_inter_threads=2) | ||
|
||
script_name = "accuracy.py" if self.args.accuracy_only \ | ||
else "benchmark.py" | ||
script_path = os.path.join( | ||
self.args.intelai_models, self.args.mode, script_name) | ||
self.command_prefix = "{} {}".format(self.python_exe, script_path) | ||
|
||
if self.args.socket_id != -1: | ||
self.command_prefix = "numactl --cpunodebind={} -l {}".format( | ||
str(self.args.socket_id), self.command_prefix) | ||
|
||
set_env_var("OMP_NUM_THREADS", self.args.num_intra_threads) | ||
|
||
self.parse_args() | ||
|
||
if not self.args.accuracy_only: | ||
# add args for the benchmark script | ||
script_args_list = [ | ||
"input_graph", "input_height", "input_width", "batch_size", | ||
"input_layer", "output_layer", "num_inter_threads", | ||
"num_intra_threads", "warmup_steps", "steps", "precision"] | ||
self.command_prefix = self.add_args_to_command( | ||
self.command_prefix, script_args_list) | ||
else: | ||
# add args for the accuracy script | ||
script_args_list = [ | ||
"input_graph", "data_location", "input_height", "input_width", | ||
"batch_size", "input_layer", "output_layer", | ||
"num_inter_threads", "num_intra_threads", "precision"] | ||
self.command_prefix = self.add_args_to_command( | ||
self.command_prefix, script_args_list) | ||
|
||
def parse_args(self): | ||
if self.custom_args is None: | ||
return | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
"--input_height", default=224, | ||
dest='input_height', type=int, help="input height") | ||
parser.add_argument( | ||
"--input_width", default=224, | ||
dest='input_width', type=int, help="input width") | ||
parser.add_argument( | ||
"--warmup_steps", dest="warmup_steps", | ||
help="number of warmup steps", | ||
type=int, default=10) | ||
parser.add_argument( | ||
"--steps", dest="steps", | ||
help="number of steps", | ||
type=int, default=50) | ||
parser.add_argument( | ||
"--input_layer", dest="input_layer", | ||
help="name of input layer", | ||
type=str, default="input") | ||
parser.add_argument( | ||
"--output_layer", dest="output_layer", | ||
help="name of output layer", | ||
type=str, default="MobilenetV1/Predictions/Reshape_1") | ||
|
||
self.args = parser.parse_args(self.custom_args, namespace=self.args) | ||
|
||
def run(self): | ||
self.run_command(self.command_prefix) |
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
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
Oops, something went wrong.