diff --git a/.github/workflows/pnnx.yml b/.github/workflows/pnnx.yml new file mode 100644 index 00000000000..5ea5eff4ba8 --- /dev/null +++ b/.github/workflows/pnnx.yml @@ -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 + + - 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 diff --git a/tools/pnnx/src/CMakeLists.txt b/tools/pnnx/src/CMakeLists.txt index d56784646b5..b1ac6f5c024 100644 --- a/tools/pnnx/src/CMakeLists.txt +++ b/tools/pnnx/src/CMakeLists.txt @@ -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() diff --git a/tools/pnnx/src/pass_ncnn/torch_istft.cpp b/tools/pnnx/src/pass_ncnn/torch_istft.cpp index 3acbe654009..9d894aba7ab 100644 --- a/tools/pnnx/src/pass_ncnn/torch_istft.cpp +++ b/tools/pnnx/src/pass_ncnn/torch_istft.cpp @@ -106,10 +106,10 @@ static int detect_window_type(const std::vector& 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; } diff --git a/tools/pnnx/src/pass_ncnn/torch_stft.cpp b/tools/pnnx/src/pass_ncnn/torch_stft.cpp index 2b2296ccbc2..8993afeb12f 100644 --- a/tools/pnnx/src/pass_ncnn/torch_stft.cpp +++ b/tools/pnnx/src/pass_ncnn/torch_stft.cpp @@ -93,10 +93,10 @@ static int detect_window_type(const std::vector& 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; } diff --git a/tools/pnnx/src/pass_ncnn/torchaudio_F_inverse_spectrogram.cpp b/tools/pnnx/src/pass_ncnn/torchaudio_F_inverse_spectrogram.cpp index d712fcc2990..0c964790fb4 100644 --- a/tools/pnnx/src/pass_ncnn/torchaudio_F_inverse_spectrogram.cpp +++ b/tools/pnnx/src/pass_ncnn/torchaudio_F_inverse_spectrogram.cpp @@ -43,10 +43,10 @@ static int detect_window_type(const std::vector& 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; } diff --git a/tools/pnnx/src/pass_ncnn/torchaudio_F_spectrogram.cpp b/tools/pnnx/src/pass_ncnn/torchaudio_F_spectrogram.cpp index 04084ad0ba6..225fab7060e 100644 --- a/tools/pnnx/src/pass_ncnn/torchaudio_F_spectrogram.cpp +++ b/tools/pnnx/src/pass_ncnn/torchaudio_F_spectrogram.cpp @@ -43,10 +43,10 @@ static int detect_window_type(const std::vector& 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; }