This repository has been archived by the owner on Aug 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wenxin Zhang <[email protected]>
- Loading branch information
1 parent
1401b43
commit 6d3ce3f
Showing
9 changed files
with
1,924 additions
and
8 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,41 @@ | ||
# | ||
# Copyright (c) 2022 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. | ||
|
||
ARG UBUNTU_VER=22.04 | ||
FROM ubuntu:${UBUNTU_VER} as devel | ||
|
||
# See http://bugs.python.org/issue19846 | ||
ENV LANG C.UTF-8 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \ | ||
aspell \ | ||
aspell-en \ | ||
python3 \ | ||
python3-pip \ | ||
python3-dev \ | ||
python3-distutils \ | ||
build-essential \ | ||
cloc \ | ||
python3.10-venv \ | ||
git | ||
|
||
RUN ln -sf $(which python3) /usr/bin/python | ||
|
||
RUN python -m pip install --no-cache-dir pylint==2.17.5\ | ||
bandit==1.7.4\ | ||
pyspelling\ | ||
pydocstyle | ||
|
||
WORKDIR / |
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,48 @@ | ||
# | ||
# Copyright (c) 2022 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. | ||
ARG UBUNTU_VER=22.04 | ||
FROM ubuntu:${UBUNTU_VER} as devel | ||
|
||
# See http://bugs.python.org/issue19846 | ||
ENV LANG C.UTF-8 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \ | ||
python3 \ | ||
python3-pip \ | ||
python3-dev \ | ||
python3-distutils \ | ||
autoconf \ | ||
build-essential \ | ||
git \ | ||
libgl1-mesa-glx \ | ||
libglib2.0-0 \ | ||
numactl \ | ||
time \ | ||
wget \ | ||
bc \ | ||
gawk \ | ||
jq \ | ||
python3.10-venv \ | ||
vim | ||
|
||
RUN ln -sf $(which python3) /usr/bin/python | ||
|
||
RUN python -m pip --no-cache-dir install --upgrade pip | ||
RUN python -m pip install --no-cache-dir setuptools | ||
|
||
RUN pip list | ||
|
||
WORKDIR / | ||
|
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,80 @@ | ||
#!/bin/bash | ||
|
||
# -------------- general approach start---------------- | ||
|
||
# 1. import this file: | ||
# source path/change_color.sh | ||
# 2. use COLOR/BG: | ||
# $VARIABLE_NAME && out_put_content && $RESET | ||
# 3. COLOR + BG: | ||
# $COLOR/BG_VARIABLE_NAME && $BG/COLOR_VARIABLE_NAME && out_put_content && $RESET | ||
# 4. custom | ||
# abbreviation(change number) | ||
# txt number range (30, 37) | ||
# bg number range (40, 47) | ||
# special effects number range (1, 7) | ||
# echo -en \\E[number1 + ; + number2 + ; + number3 + m" | ||
# e.g - BG_GRAY+LIGHT_RED = "echo -en \\E[47;31m" | ||
|
||
# -------------- general approach end----------------== | ||
|
||
# general setting | ||
# ------------- light_color start---------------- | ||
# black | ||
LIGHT_BLACK="echo -en \\E[30m" | ||
# red | ||
LIGHT_RED="echo -en \\E[31m" | ||
# green | ||
LIGHT_GREEN="echo -en \\E[32m" | ||
# yellow | ||
LIGHT_YELLOW="echo -en \\E[33m" | ||
# blue | ||
LIGHT_BLUE="echo -en \\E[34m" | ||
# purple | ||
LIGHT_PURPLE="echo -en \\E[35m" | ||
# cyan | ||
LIGHT_CYAN="echo -en \\E[36m" | ||
# gray | ||
LIGHT_GRAY="echo -en \\E[37m" | ||
# ------------- light_color end---------------- | ||
|
||
# ------------- bold_color start---------------- | ||
# black | ||
BOLD_BLACK="echo -en \\E[1;30m" | ||
# red | ||
BOLD_RED="echo -en \\E[1;31m" | ||
# green | ||
BOLD_GREEN="echo -en \\E[1;32m" | ||
# yellow | ||
BOLD_YELLOW="echo -en \\E[1;33m" | ||
# blue | ||
BOLD_BLUE="echo -en \\E[1;34m" | ||
# purple | ||
BOLD_PURPLE="echo -en \\E[1;35m" | ||
# cyan | ||
BOLD_CYAN="echo -en \\E[1;36m" | ||
# gray | ||
BOLD_GRAY="echo -en \\E[1;37m" | ||
# ------------- bold_color end---------------- | ||
|
||
# ------------- background_color start---------------- | ||
# black | ||
BG_BLACK="echo -en \\E[40m" | ||
# red | ||
BG_RED="echo -en \\E[41m" | ||
# green | ||
BG_GREEN="echo -en \\E[42m" | ||
# yellow | ||
BG_YELLOW="echo -en \\E[43m" | ||
# blue | ||
BG_BLUE="echo -en \\E[44m" | ||
# purple | ||
BG_PURPLE="echo -en \\E[45m" | ||
# cyan | ||
BG_CYAN="echo -en \\E[46m" | ||
# gray | ||
BG_GRAY="echo -en \\E[47m" | ||
# ------------- background_color end---------------- | ||
|
||
# close | ||
RESET="echo -en \\E[0m" |
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 @@ | ||
#!/bin/bash | ||
source /intel-extension-for-transformers/.github/workflows/script/change_color.sh | ||
|
||
cd /intel-extension-for-transformers | ||
export CMAKE_ARGS="-DNE_DNNL_CACHE_DIR=/cache" | ||
$BOLD_YELLOW && echo "---------------- git submodule update --init --recursive -------------" && $RESET | ||
git config --global --add safe.directory "*" | ||
git submodule update --init --recursive | ||
|
||
|
||
$BOLD_YELLOW && echo "---------------- run python setup.py sdist bdist_wheel -------------" && $RESET | ||
python setup.py bdist_wheel | ||
|
||
|
||
$BOLD_YELLOW && echo "---------------- pip install binary -------------" && $RESET | ||
pip install dist/intel_extension_for_transformers*.whl | ||
pip list |
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,88 @@ | ||
import numpy as np | ||
import re | ||
import sys | ||
import os | ||
def calculate_percentile(data, percentile): | ||
return np.percentile(data, percentile, method="closest_observation") | ||
|
||
def calculate_mean(data): | ||
return np.mean(data) | ||
|
||
def parse_output_file(file_path): | ||
predictions = [] | ||
with open(file_path, 'r', encoding='UTF-8', errors='ignore') as file: | ||
for line in file: | ||
match = re.search(r"time: (\d+\.\d+)ms", line) | ||
if match: | ||
prediction_time = float(match.group(1)) # Assuming the prediction time is in the second column | ||
predictions.append(prediction_time) | ||
return predictions | ||
def parse_memory_file(memory_file): | ||
memory_values = [] | ||
if os.path.exists(memory_file): | ||
with open(memory_file, 'r') as file: | ||
for line in file: | ||
match = re.search(r"Private \s+\d+\.\d+\s+ \d+\.\d+\s+ (\d+\.\d+)", line) | ||
if match: | ||
memory_value = float(match.group(1)) | ||
memory_values.append(memory_value) | ||
else: | ||
print("memory_file is not exist") | ||
memory_values.append(0.0) | ||
return memory_values | ||
|
||
|
||
if __name__ == "__main__": | ||
if len(sys.argv) < 8: | ||
print("Usage: python executor.py output_file") | ||
sys.exit(1) | ||
|
||
output_file = sys.argv[1] | ||
model = sys.argv[2] | ||
precision = sys.argv[3] | ||
cores_per_instance = sys.argv[4] | ||
batch_size = sys.argv[5] | ||
model_input = sys.argv[6] | ||
model_output = sys.argv[7] | ||
memory_file = os.environ.get("WORKING_DIR") + "/memory.txt" | ||
predictions = parse_output_file(output_file) | ||
first_token_latency = predictions[0] | ||
p90 = calculate_percentile(predictions, 90) | ||
p99 = calculate_percentile(predictions, 99) | ||
latency_mean = calculate_mean(predictions[1:]) | ||
total_latency = np.sum(predictions) | ||
|
||
print("P90: {:.2f} ms".format(p90)) | ||
print("P99: {:.2f} ms".format(p99)) | ||
print("average_latency: {:.2f} ms".format(latency_mean)) | ||
print("first_token_latency: {:.2f} ms".format(first_token_latency)) | ||
|
||
memory_values = parse_memory_file(memory_file) | ||
sorted_memory_values = sorted(memory_values, reverse=True) | ||
top_50_percent = sorted_memory_values[:int(len(sorted_memory_values) * 0.5)] | ||
memory_mean = calculate_mean(top_50_percent) | ||
|
||
print("Memory Mean (Top 50%): {:.2f}".format(memory_mean)) | ||
log_file = os.environ.get("WORKING_DIR") + "/cpp_graph_summary.log" | ||
link = os.environ.get("WORKING_DIR") + os.path.basename(output_file) | ||
with open (log_file, 'a') as f: | ||
f.write("engine,") | ||
f.write("latency,") | ||
f.write(model + ",") | ||
f.write(precision + ",") | ||
f.write(batch_size + ",") | ||
f.write(model_input + ",") | ||
f.write(model_output + ",") | ||
f.write(cores_per_instance + ",,") | ||
f.write("{:.2f},".format(first_token_latency)) | ||
f.write("{:.2f},".format(latency_mean)) | ||
f.write("{:.2f},".format(total_latency)) | ||
f.write("{:.2f},".format(memory_mean)) | ||
f.write(link + ",") | ||
f.write("{:.2f},".format(p90)) | ||
f.write("{:.2f},".format(p99)) | ||
#f.write(",latency:") | ||
#for latency in predictions: | ||
# f.write(",{:.2f}".format(latency)) | ||
f.write("\n") | ||
f.close() |
Oops, something went wrong.