[Python Tools] Fix several problems in cross-check-tool (#2170)
This commit is contained in:
parent
75601e62ed
commit
f7ee106b21
@ -36,7 +36,7 @@ from utils import get_config_dictionary, get_layers_list, print_output_layers, i
|
|||||||
|
|
||||||
|
|
||||||
@error_handling('plugin of \'{plugin.device}\' device config \'{config}\' loading')
|
@error_handling('plugin of \'{plugin.device}\' device config \'{config}\' loading')
|
||||||
def set_plugin_config(core: IECore, device : str, config: str = None):
|
def set_plugin_config(core: IECore, device: str, config: str = None):
|
||||||
core.set_config(get_config_dictionary(config_file=config), device_name=device)
|
core.set_config(get_config_dictionary(config_file=config), device_name=device)
|
||||||
|
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ def get_net_copy_with_output(model: str, output: str, core: IECore):
|
|||||||
@error_handling('getting model layers info')
|
@error_handling('getting model layers info')
|
||||||
def get_model_info(net: IENetwork):
|
def get_model_info(net: IENetwork):
|
||||||
func = ng.function_from_cnn(net)
|
func = ng.function_from_cnn(net)
|
||||||
ops = func.get_ops()
|
ops = func.get_ordered_ops()
|
||||||
return ops, net.input_info, net.outputs
|
return ops, net.input_info, net.outputs
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ def get_perf_counts(executable_network):
|
|||||||
|
|
||||||
|
|
||||||
@error_handling('getting inference results for outputs: \'{output}\'')
|
@error_handling('getting inference results for outputs: \'{output}\'')
|
||||||
def infer(net: IENetwork, core: IECore, device : str, inputs: dict, output: list):
|
def infer(net: IENetwork, core: IECore, device: str, inputs: dict, output: list):
|
||||||
executable_network = get_exec_net(core=core, net=net, device=device)
|
executable_network = get_exec_net(core=core, net=net, device=device)
|
||||||
infer_dict = get_infer_results(executable_network=executable_network, inputs=inputs)
|
infer_dict = get_infer_results(executable_network=executable_network, inputs=inputs)
|
||||||
pc = get_perf_counts(executable_network=executable_network)
|
pc = get_perf_counts(executable_network=executable_network)
|
||||||
@ -122,7 +122,7 @@ def infer(net: IENetwork, core: IECore, device : str, inputs: dict, output: list
|
|||||||
|
|
||||||
@error_handling('getting inference results for outputs: \'{output}\'')
|
@error_handling('getting inference results for outputs: \'{output}\'')
|
||||||
def overall_accuracy_check(model: str, ref_model: str, out_layers: list, ref_out_layers: list, inputs: dict,
|
def overall_accuracy_check(model: str, ref_model: str, out_layers: list, ref_out_layers: list, inputs: dict,
|
||||||
ref_inputs: dict, core: IECore, device: str, ref_core: IECore, ref_device : str, layers: str,
|
ref_inputs: dict, core: IECore, device: str, ref_core: IECore, ref_device: str, layers: str,
|
||||||
num_of_iterations: int):
|
num_of_iterations: int):
|
||||||
global_times, ref_global_times = [], []
|
global_times, ref_global_times = [], []
|
||||||
if layers in ['None', None]:
|
if layers in ['None', None]:
|
||||||
@ -164,7 +164,8 @@ def one_ir_mode(args):
|
|||||||
if out_layer not in results:
|
if out_layer not in results:
|
||||||
continue
|
continue
|
||||||
out_blob, pc = results[out_layer]
|
out_blob, pc = results[out_layer]
|
||||||
ref_results = infer(net=net_copy, core=ref_core, device=args.reference_device, inputs=inputs, output=[out_layer])
|
ref_results = infer(net=net_copy, core=ref_core, device=args.reference_device,
|
||||||
|
inputs=inputs, output=[out_layer])
|
||||||
if out_layer not in ref_results:
|
if out_layer not in ref_results:
|
||||||
continue
|
continue
|
||||||
ref_out_blob, ref_pc = ref_results[out_layer]
|
ref_out_blob, ref_pc = ref_results[out_layer]
|
||||||
|
@ -506,16 +506,23 @@ def manage_user_outputs_with_mapping(mapping, reference_mapping, user_layers):
|
|||||||
def get_layers_list(all_layers: list, inputs: dict, outputs: list, layers: str):
|
def get_layers_list(all_layers: list, inputs: dict, outputs: list, layers: str):
|
||||||
if layers is not None and layers != 'None':
|
if layers is not None and layers != 'None':
|
||||||
if layers == 'all':
|
if layers == 'all':
|
||||||
return {layer.get_friendly_name(): layer for layer in all_layers if layer.get_type_name() not in ['Const']}
|
return {layer.get_friendly_name(): layer for layer in all_layers \
|
||||||
|
if layer.get_type_name() not in ['Constant', 'Result']}
|
||||||
else:
|
else:
|
||||||
|
all_layers_names = {op.get_friendly_name() : op for op in all_layers}
|
||||||
user_layers = [layer.strip() for layer in layers.split(',')]
|
user_layers = [layer.strip() for layer in layers.split(',')]
|
||||||
layers_to_check = []
|
layers_to_check = []
|
||||||
for user_layer in user_layers:
|
for user_layer in user_layers:
|
||||||
if user_layer not in all_layers:
|
if user_layer not in all_layers_names:
|
||||||
raise Exception("Layer {} doesn't exist in the model".format(user_layer))
|
raise Exception("Layer {} doesn't exist in the model".format(user_layer))
|
||||||
if user_layer in inputs:
|
if user_layer in inputs:
|
||||||
raise Exception("Layer {} is input layer. Can not proceed".format(user_layer))
|
raise Exception("Layer {} is input layer. Can not proceed".format(user_layer))
|
||||||
layers_to_check.append(user_layer)
|
if all_layers_names[user_layer].get_type_name() != 'Result':
|
||||||
|
layers_to_check.append(user_layer)
|
||||||
|
else:
|
||||||
|
# if layer type is Result - add previous layer
|
||||||
|
prev_layer = all_layers[len(all_layers)-2]
|
||||||
|
layers_to_check.append(prev_layer.get_friendly_name())
|
||||||
return layers_to_check
|
return layers_to_check
|
||||||
else:
|
else:
|
||||||
return outputs
|
return outputs
|
||||||
|
Loading…
Reference in New Issue
Block a user