Skip to content
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

pnnx fix macos and windows build, add quick test ci #5838

Merged
merged 16 commits into from
Dec 23, 2024
49 changes: 49 additions & 0 deletions .github/workflows/pnnx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: pnnx
on:
push:
branches: [master]
paths:
- '.github/workflows/pnnx.yml'
- 'tools/pnnx/**'
- '!tools/pnnx/README.md'
pull_request:
branches: [master]
paths:
- '.github/workflows/pnnx.yml'
- 'tools/pnnx/**'
- '!tools/pnnx/README.md'
concurrency:
group: pnnx-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v4
Copy link
Preview

Copilot AI Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version 'v4' for 'actions/checkout' does not exist. It should be 'v3'.

Suggested change
- uses: actions/checkout@v4
- uses: actions/checkout@v3

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

- name: setup-pytorch
run: |
export PYTHONUSERBASE=$GITHUB_WORKSPACE/torch
pip install --user torch --index-url https://download.pytorch.org/whl/cpu

- name: build-pnnx
run: |
export PYTHONUSERBASE=$GITHUB_WORKSPACE/torch
cd tools/pnnx
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -j 4

- name: quick-test
run: |
export PYTHONUSERBASE=$GITHUB_WORKSPACE/torch
cd tools/pnnx
cd build && ctest --output-on-failure -R test_nn_Conv
4 changes: 4 additions & 0 deletions tools/pnnx/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,10 @@ if(PROTOBUF_FOUND)
set_property(TARGET onnxruntime::onnxruntime APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
set_property(TARGET onnxruntime::onnxruntime APPEND PROPERTY INTERFACE_LINK_LIBRARIES protobuf::libprotobuf)
endif()

if(APPLE)
set_property(TARGET onnxruntime::onnxruntime APPEND PROPERTY INTERFACE_LINK_LIBRARIES "-framework CoreFoundation")
endif()
endif()
endif()

Expand Down
4 changes: 2 additions & 2 deletions tools/pnnx/src/pass_ncnn/torch_istft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ static int detect_window_type(const std::vector<float>& window_data)
if (!NearlyEqual(window_data[i], 1.f, 0.001))
is_one = false;

if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * M_PI * i / winlen)), 0.001))
if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * 3.14159265358979323846 * i / winlen)), 0.001))
is_hann = false;

if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * M_PI * i / winlen), 0.001))
if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * 3.14159265358979323846 * i / winlen), 0.001))
is_hamming = false;
}

Expand Down
4 changes: 2 additions & 2 deletions tools/pnnx/src/pass_ncnn/torch_stft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ static int detect_window_type(const std::vector<float>& window_data)
if (!NearlyEqual(window_data[i], 1.f, 0.001))
is_one = false;

if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * M_PI * i / winlen)), 0.001))
if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * 3.14159265358979323846 * i / winlen)), 0.001))
is_hann = false;

if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * M_PI * i / winlen), 0.001))
if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * 3.14159265358979323846 * i / winlen), 0.001))
is_hamming = false;
}

Expand Down
4 changes: 2 additions & 2 deletions tools/pnnx/src/pass_ncnn/torchaudio_F_inverse_spectrogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ static int detect_window_type(const std::vector<float>& window_data)
if (!NearlyEqual(window_data[i], 1.f, 0.001))
is_one = false;

if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * M_PI * i / winlen)), 0.001))
if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * 3.14159265358979323846 * i / winlen)), 0.001))
is_hann = false;

if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * M_PI * i / winlen), 0.001))
if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * 3.14159265358979323846 * i / winlen), 0.001))
is_hamming = false;
}

Expand Down
4 changes: 2 additions & 2 deletions tools/pnnx/src/pass_ncnn/torchaudio_F_spectrogram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ static int detect_window_type(const std::vector<float>& window_data)
if (!NearlyEqual(window_data[i], 1.f, 0.001))
is_one = false;

if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * M_PI * i / winlen)), 0.001))
if (!NearlyEqual(window_data[i], 0.5f * (1 - cos(2 * 3.14159265358979323846 * i / winlen)), 0.001))
is_hann = false;

if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * M_PI * i / winlen), 0.001))
if (!NearlyEqual(window_data[i], 0.54f - 0.46f * cos(2 * 3.14159265358979323846 * i / winlen), 0.001))
is_hamming = false;
}

Expand Down
Loading