Skip to content

Add hpu ci #1634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backends/intel_hpu/tests/unittests/test_relu.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ def test_static_api(self):
res = exe.run(feed={"X": self.x_np}, fetch_list=[out1, out2])
out_ref = np.maximum(self.x_np, 0)
for r in res:
print("TestReluAPI:test_static_api:out_ref=", out_ref)
print("TestReluAPI:test_static_api:r=", r)
np.testing.assert_allclose(out_ref, r, rtol=1e-05)

def test_dygraph_api(self):
Expand All @@ -123,6 +125,8 @@ def test_dygraph_api(self):
out2 = self.relu(x)
out_ref = np.maximum(self.x_np, 0)
for r in [out1, out2]:
print("TestReluAPI:test_dygraph_api:out_ref=", out_ref)
print("TestReluAPI:test_dygraph_api:r=", r.numpy())
np.testing.assert_allclose(out_ref, r.numpy(), rtol=1e-05)
paddle.enable_static()

Expand Down
44 changes: 44 additions & 0 deletions backends/intel_hpu/tools/pr_hpu_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2025 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.

set -ex

WORKSPACE=`pwd`
echo "Install whl"
python -m pip install --pre paddlepaddle -i https://www.paddlepaddle.org.cn/packages/nightly/cpu/
python -c "import paddle; print(paddle.__version__)"
python -c "import paddle; print(paddle.version.commit)"
python -m pip install lxml numpy==1.26.4
cd ${WORKSPACE}/PaddleCustomDevice/backends/intel_hpu/custom_ops
python setup.py install


echo "Start build"
cd ${WORKSPACE}/PaddleCustomDevice/backends/intel_hpu
mkdir -p build && cd build
cmake ..
make -j $(nproc)

# Update lib.so
rm -rf /usr/lib/habanalabs/libcustom_tpc_perf_lib.so
wget --no-proxy -q https://paddle-ci.cdn.bcebos.com/libcustom_tpc_perf_lib.so -P /usr/lib/habanalabs/
cp /usr/lib/habanalabs/libcustom_tpc_perf_lib.so ${WORKSPACE}/PaddleCustomDevice/backends/intel_hpu/build/

python -m pip install --force-reinstall -U dist/paddle*.whl
export PYTHONPATH=/workspace/PaddleCustomDevice/python:/workspace/PaddleCustomDevice/python/tests:$PYTHONPATH

echo "Start Test"
python ${WORKSPACE}/PaddleCustomDevice/backends/intel_hpu/tests/pr-test-run.py --test_path ${WORKSPACE}/PaddleCustomDevice/backends/intel_hpu/tests/unittests/ --junit ${WORKSPACE}/ci.xml --filter stable --platform gaudi2 --force_exit
python ${WORKSPACE}/PaddleCustomDevice/backends/intel_hpu/tools/testresult_analyse.py --input_file ${WORKSPACE}/ci.xml >>${WORKSPACE}/ci.log
cat ${WORKSPACE}/ci.log
57 changes: 57 additions & 0 deletions backends/intel_hpu/tools/testresult_analyse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/python3

# Copyright (c) 2025 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 os
import argparse

import xml.etree.ElementTree as ET

cmd_args = {}
parser = argparse.ArgumentParser(
description="help script for run the test",
add_help=True,
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument("--input_file", type=str, help="xml test result input file")

cmd_args.update(vars(parser.parse_args()))

input_file_xml = "test_result.xml"
if cmd_args["input_file"]:
if os.path.exists(cmd_args["input_file"]) is False:
print("test result file is not exist")
exit(2)
input_file_xml = cmd_args["input_file"]

tree = ET.parse(input_file_xml)
root = tree.getroot()

results = {"passed": 0, "failed": 0, "skipped": 0}

for testcase in root.findall("testcase"):
name = testcase.get("name")
if testcase.find("failure") is not None:
results["failed"] += 1
print(f"\tTestcase: {name} failed")
elif testcase.find("skipped") is not None:
results["skipped"] += 1
else:
results["passed"] += 1
print(f"\tTestcase: {name} passed")

print(f"\tPassed tests: {results['passed']}")
print(f"\tFailed tests: {results['failed']}")
print(f"\tSkipped tests: {results['skipped']}")