-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Auto_Scan]Summary statistics of op/pass (#8079)
- Loading branch information
1 parent
656fb52
commit d893d7f
Showing
5 changed files
with
238 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# Copyright (c) 2021 PaddlePaddle 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. | ||
|
||
import pickle | ||
from pathlib import Path | ||
import os | ||
|
||
statics_data = { | ||
"targets": set(), | ||
"all_test_ops": { | ||
"Host": set(), | ||
"X86": set(), | ||
"ARM": set(), | ||
"OpenCL": set(), | ||
"Metal": set() | ||
}, | ||
"success_ops": { | ||
"Host": set(), | ||
"X86": set(), | ||
"ARM": set(), | ||
"OpenCL": set(), | ||
"Metal": set() | ||
}, | ||
"out_diff_ops": { | ||
"Host": set(), | ||
"X86": set(), | ||
"ARM": set(), | ||
"OpenCL": set(), | ||
"Metal": set() | ||
}, | ||
"not_supported_ops": { | ||
"Host": set(), | ||
"X86": set(), | ||
"ARM": set(), | ||
"OpenCL": set(), | ||
"Metal": set() | ||
}, | ||
} | ||
static_file = Path("./statics_data") | ||
static_file_path_str = "./statics_data" | ||
|
||
|
||
# coding=utf-8 | ||
def set_value(kind, target, op): | ||
if not static_file.exists(): | ||
global statics_data | ||
else: | ||
with open(static_file_path_str, "rb") as f: | ||
statics_data = pickle.load(f) | ||
|
||
statics_data["targets"].add(target) | ||
statics_data[kind][target].add(op) | ||
|
||
with open(static_file_path_str, "wb") as f: | ||
pickle.dump(statics_data, f) | ||
|
||
|
||
def set_all_test_ops(target, op): | ||
set_value("all_test_ops", target, op) | ||
|
||
|
||
def set_success_ops(target, op): | ||
set_value("success_ops", target, op) | ||
|
||
|
||
def set_out_diff_ops(target, op): | ||
set_value("out_diff_ops", target, op) | ||
|
||
|
||
def set_not_supported_ops(target, op): | ||
set_value("not_supported_ops", target, op) | ||
|
||
|
||
def display(): | ||
print("----------------------Unit Test Summary---------------------") | ||
with open("./statics_data", "rb") as f: | ||
statics_data = pickle.load(f) | ||
targets = statics_data["targets"] | ||
|
||
for target in targets: | ||
all_test_ops = statics_data["all_test_ops"][target] | ||
not_supported_ops = statics_data["not_supported_ops"][target] | ||
out_diff_ops = statics_data["out_diff_ops"][target] | ||
success_ops = statics_data["success_ops"][ | ||
target] - not_supported_ops - out_diff_ops | ||
|
||
print("Target =", target) | ||
print("Number of test ops =", len(all_test_ops)) | ||
print("Number of success ops =", len(success_ops)) | ||
print("Number of not supported ops =", len(not_supported_ops)) | ||
print("Number of output diff ops =", len(out_diff_ops)) | ||
print("\nDetails:") | ||
print("Success ops:") | ||
print(list(success_ops)) | ||
print("\nNot supported ops:") | ||
print(list(not_supported_ops)) | ||
print("\nOutput diff ops:") | ||
print(list(out_diff_ops)) | ||
print("\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
display() |
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
#!/bin/bash | ||
set -e | ||
unset GREP_OPTIONS | ||
ARCH="" | ||
TEST_FILE="" | ||
COLLECT_TEST_INFO=false | ||
function get_inputs { | ||
# Parse command line. | ||
for i in "$@"; do | ||
case $i in | ||
--target=*) | ||
ARCH="${i#*=}" | ||
shift | ||
;; | ||
test_info) | ||
COLLECT_TEST_INFO=true | ||
shift | ||
;; | ||
*) | ||
TEST_FILE="$i" | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
function run_test { | ||
if [[ $ARCH = "" ]] || [[ $1 = "" ]]; then | ||
echo "Error input: ./auto_scan test_assign_op.py --target=Host" | ||
exit 1 | ||
fi | ||
|
||
if [[ $ARCH = "ARM" ]] || [[ $ARCH = "OpenCL" ]] || [[ $ARCH = "Metal" ]]; then | ||
cd ../rpc_service | ||
sh start_rpc_server.sh | ||
cd ../op | ||
python3.8 $1 --target=$ARCH | ||
else | ||
python3.7 $1 --target=$ARCH | ||
fi | ||
} | ||
|
||
get_inputs $@ | ||
|
||
if [ $COLLECT_TEST_INFO = true ]; then | ||
tests=$(ls | grep test) | ||
for test in $tests; do | ||
run_test $test | ||
done | ||
else | ||
run_test $TEST_FILE | ||
rm -f ../.test_num ../.test_names | ||
fi | ||
|
||
if [[ $ARCH = "ARM" ]] || [[ $ARCH = "OpenCL" ]] || [[ $ARCH = "Metal" ]]; then | ||
python3.9 ../global_var_model.py | ||
else | ||
python3.7 ../global_var_model.py | ||
fi |
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,59 @@ | ||
#!/bin/bash | ||
set -e | ||
unset GREP_OPTIONS | ||
ARCH="" | ||
TEST_FILE="" | ||
COLLECT_TEST_INFO=false | ||
function get_inputs { | ||
# Parse command line. | ||
for i in "$@"; do | ||
case $i in | ||
--target=*) | ||
ARCH="${i#*=}" | ||
shift | ||
;; | ||
test_info) | ||
COLLECT_TEST_INFO=true | ||
shift | ||
;; | ||
*) | ||
# unknown option | ||
TEST_FILE="$i" | ||
;; | ||
esac | ||
done | ||
} | ||
|
||
function run_test { | ||
if [[ $ARCH = "" ]] || [[ $1 = "" ]]; then | ||
echo "Error input: ./auto_scan test_assign_op.py --target=Host" | ||
exit 1 | ||
fi | ||
|
||
if [[ $ARCH = "ARM" ]] || [[ $ARCH = "OpenCL" ]] || [[ $ARCH = "Metal" ]]; then | ||
cd ../rpc_service | ||
sh start_rpc_server.sh | ||
cd ../op | ||
python3.8 $1 --target=$ARCH | ||
else | ||
python3.7 $1 --target=$ARCH | ||
fi | ||
} | ||
|
||
get_inputs $@ | ||
|
||
if [ $COLLECT_TEST_INFO = true ]; then | ||
tests=$(ls | grep test) | ||
for test in $tests; do | ||
run_test $test | ||
done | ||
else | ||
run_test $TEST_FILE | ||
rm -f ../.test_num ../.test_names | ||
fi | ||
|
||
if [[ $ARCH = "ARM" ]] || [[ $ARCH = "OpenCL" ]] || [[ $ARCH = "Metal" ]]; then | ||
python3.9 ../global_var_model.py | ||
else | ||
python3.7 ../global_var_model.py | ||
fi |