π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
feat: migrate GitHub Actions workflows to local repository (#3295)
Meggison Oritsemisan129a0cf5b9f0
diff --git a/.github/actions/coverage/action.yml b/.github/actions/coverage/action.ymlnew file mode 100644index 000000000..afbd682ee--- /dev/null+++ b/.github/actions/coverage/action.yml@@ -0,0 +1,64 @@+name: tests-coverage+description: "Run CPU tests with coverage collection and artifact upload"++inputs:+ python-version:+ description: "Python version to use"+ required: false+ default: "3.12"+ pytorch-version:+ description: "PyTorch version to use"+ required: false+ default: 2.5.1+ os:+ description: "Operating system to run on"+ required: false+ default: ubuntu-latest+ pytorch-dtype:+ description: "PyTorch data type for testing"+ required: false+ default: float32+ pytorch-device:+ description: "PyTorch device for testing"+ required: false+ default: cpu+ pytest-extra:+ description: "Extra pytest arguments"+ required: false+ default: --timeout=30 -k "not test_dynamo"+ coverage-artifact:+ description: "Name of coverage artifact"+ required: false+ default: coverage+ continue-on-error:+ description: "Whether to continue on error"+ required: false+ default: "false"+ ref:+ description: "Git reference to checkout"+ default: ${{ github.sha }}++runs:+ using: "composite"+ steps:+ - name: Setting environment on ${{ inputs.os }} with python ${{ inputs.python-version }} and pytorch ${{ inputs.pytorch-version }}+ uses: ./.github/actions/env #@v1.13.0+ with:+ python-version: ${{ inputs.python-version }}+ pytorch-version: ${{ inputs.pytorch-version }}+ ref: ${{ inputs.ref }}++ - name: Run CPU tests coverage ${{ inputs.pytorch-dtype }}+ continue-on-error: ${{ inputs.continue-on-error }}+ shell: bash -l {0}+ run: |+ coverage erase+ coverage run --data-file=${{ inputs.coverage-artifact }} -m pytest -v ./tests/ --device=${{ inputs.pytorch-device }} --dtype=${{ inputs.pytorch-dtype }} ${{ inputs.pytest-extra }}++ - name: Upload coverage results+ uses: actions/upload-artifact@v4+ with:+ name: ${{ inputs.coverage-artifact }}+ path: ${{ inputs.coverage-artifact }}+ if-no-files-found: error+ retention-days: 1diff --git a/.github/actions/env/action.yml b/.github/actions/env/action.ymlnew file mode 100644index 000000000..10902edc8--- /dev/null+++ b/.github/actions/env/action.yml@@ -0,0 +1,98 @@+name: Setup Kornia dev environment+description: "Set up Python, PyTorch, and dependencies for Kornia development"++inputs:+ python-version:+ description: "The python version desired."+ required: true+ default: "3.13"++ pytorch-version:+ description: "The pytorch version desired."+ required: true+ default: "2.5.1"++ ref:+ description: "Git reference to checkout"+ default: ${{ github.sha }}++ fetch-depth:+ description: "Number of commits to fetch"+ default: "1"++ extra-deps:+ description: "Dependencies to be installed manually before installing kornia."+ default: ""+ required: false++runs:+ using: "composite"+ steps:+ - name: Setup environment+ uses: actions/setup-python@v5+ with:+ python-version: ${{ inputs.python-version }}++ - name: Install UV+ shell: bash+ run: pip install uv++ - if: ${{ contains(fromJson('["nightly"]'), inputs.pytorch-version ) }}+ name: Install PyTorch nightly+ shell: bash+ run: uv pip install --system numpy --pre torch[dynamo] ${{ inputs.extra-deps }} --force-reinstall --extra-index-url https://download.pytorch.org/whl/nightly/cpu/++ - if: ${{ contains(fromJson('["nightly"]'), inputs.pytorch-version ) == false}}+ name: Install pytorch+ shell: bash+ run: |+ if [ "$RUNNER_OS" == "Linux" ] || [ "$RUNNER_OS" == "Windows" ]; then+ uv pip install --system torch==${{ inputs.pytorch-version }}+cpu ${{ inputs.extra-deps }} --find-links https://download.pytorch.org/whl/torch+ else+ uv pip install --system torch==${{ inputs.pytorch-version }} ${{ inputs.extra-deps }} --find-links https://download.pytorch.org/whl/torch+ fi++ - if: ${{ contains(fromJson('["1.9.1", "1.10.2", "1.11.0", "1.12.1", "1.13.1", "2.0.1", "2.1.2", "2.2.2"]'), inputs.pytorch-version) }}+ name: Install numpy for old torchs+ shell: bash+ run: uv pip install --system "numpy<2.0.0"++ - name: Install Kornia dev+ shell: bash+ run: uv pip install --system --editable .[dev,x]++ - name: Handle compatibility for older PyTorch versions+ shell: bash+ run: |+ PYTORCH_VERSION="${{ inputs.pytorch-version }}"++ # Install compatible transformers for PyTorch < 2.3+ if [[ $(python -c "+ import packaging.version as pv+ print(pv.parse('$PYTORCH_VERSION') < pv.parse('2.3.0'))+ ") == "True" ]]; then+ echo "Installing compatible transformers for PyTorch $PYTORCH_VERSION"+ uv pip install --system "transformers<4.35.0"+ fi++ # Ensure accelerate is installed (should come from kornia[x] but verify)+ python -c "import accelerate" 2>/dev/null || uv pip install --system accelerate++ - name: Check torch version+ shell: bash+ run: |+ INSTALLED_VERSION=$(python -c "import torch; print(torch.__version__)")+ echo "Installed PyTorch version: $INSTALLED_VERSION"+ echo "Requested PyTorch version: ${{ inputs.pytorch-version }}"+ # For PyTorch 1.9.1, accelerate may upgrade to a newer version+ if [[ "${{ inputs.pytorch-version }}" == "1.9.1" && "$INSTALLED_VERSION" != "1.9.1" ]]; then+ echo "PyTorch 1.9.1 was upgraded by accelerate to $INSTALLED_VERSION"+ else+ pip show torch | grep ${{ inputs.pytorch-version }} || false+ fi++ - name: Print dependencies and kornia version+ shell: bash+ run: |+ python -c "import torch;print('Pytorch version: ', torch.__version__)"+ python -c "import kornia;print('Kornia version: ', kornia.__version__)"diff --git a/.github/actions/tests/action.yml b/.github/actions/tests/action.ymlnew file mode 100644index 000000000..9d86ea18b--- /dev/null+++ b/.github/actions/tests/action.yml@@ -0,0 +1,47 @@+name: pytest+description: "Run CPU tests with pytest"++inputs:+ python-version:+ description: "Python version to use"+ required: false+ default: "3.12"+ pytorch-version:+ description: "PyTorch version to use"+ required: false+ default: 2.5.1+ os:+ description: "Operating system to run on"+ required: false+ default: ubuntu-latest+ pytorch-dtype:+ description: "PyTorch data type for testing"+ required: false+ default: float32+ pytorch-device:+ description: "PyTorch device for testing"+ required: false+ default: cpu+ pytest-extra:+ description: "Extra pytest arguments"+ required: false+ default: --timeout=30 -k "not test_dynamo"+ ref:+ description: "Git reference to checkout"+ default: ${{ github.sha }}+++runs:+ using: "composite"+ steps:+ - name: Setting environment on ${{ inputs.os }} with python ${{ inputs.python-version }} and pytorch ${{ inputs.pytorch-version }}+ uses: ./.github/actions/env #@v1.13.0+ with:+ python-version: ${{ inputs.python-version }}+ pytorch-version: ${{ inputs.pytorch-version }}+ ref: ${{ inputs.ref }}++ - name: Run CPU tests ${{ inputs.pytorch-dtype }}+ shell: bash -l {0}+ run: |+ pytest -v ./tests/ --device=${{ inputs.pytorch-device }} --dtype=${{ inputs.pytorch-dtype }} ${{ inputs.pytest-extra }}diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.ymlnew file mode 100644index 000000000..51aa469f0--- /dev/null+++ b/.github/workflows/coverage.yml@@ -0,0 +1,179 @@+on:+ workflow_call:+ inputs:+ python-version:+ required: false+ type: string+ default: "3.11"+ pytorch-version:+ required: false+ type: string+ default: "2.5.1"+ pytorch-device:+ required: false+ type: string+ default: "cpu"+ os:+ required: false+ type: string+ default: ubuntu-latest+ ref:+ required: false+ type: string+ default: ${{ github.sha }}+ cache-path:+ required: false+ type: string+ cache-key:+ required: false+ type: string+ cache-restore-keys:+ required: false+ type: string++jobs:+ slow:+ # Only run tests with slow marker which aren't dynamo tests+ runs-on: ${{ inputs.os }}+ strategy:+ fail-fast: true+ matrix:+ pytorch-dtype: ["float32", "float64"]++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ ref: ${{ inputs.ref }}++ - name: Restore cache+ if: "${{ inputs.cache-path != '' }}"+ uses: actions/cache/restore@v4+ with:+ path: ${{ inputs.cache-path }}+ key: ${{ inputs.cache-key }}+ restore-keys: ${{ inputs.cache-restore-keys }}++ - uses: ./.github/actions/coverage+ with:+ os: ${{ inputs.os }}+ python-version: ${{ inputs.python-version }}+ pytorch-version: ${{ inputs.pytorch-version }}+ pytorch-dtype: ${{ matrix.pytorch-dtype }}+ pytorch-device: ${{ inputs.pytorch-device }}+ pytest-extra: '--runslow -k "slow and not test_dynamo"'+ coverage-artifact: coverage-slow-${{ matrix.pytorch-dtype }}+ ref: ${{ inputs.ref }}++ dynamo:+ # Run all dynamo (torch.compile) related tests+ runs-on: ${{ inputs.os }}+ strategy:+ fail-fast: true+ matrix:+ pytorch-dtype: ["float32"]++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ ref: ${{ inputs.ref }}++ - name: Restore cache+ if: "${{ inputs.cache-path != '' }}"+ uses: actions/cache/restore@v4+ with:+ path: ${{ inputs.cache-path }}+ key: ${{ inputs.cache-key }}+ restore-keys: ${{ inputs.cache-restore-keys }}++ - uses: ./.github/actions/coverage+ with:+ os: ${{ inputs.os }}+ python-version: ${{ inputs.python-version }}+ pytorch-version: ${{ inputs.pytorch-version }}+ pytorch-dtype: ${{ matrix.pytorch-dtype }}+ pytorch-device: ${{ inputs.pytorch-device }}+ pytest-extra: '--runslow -k "test_dynamo"'+ coverage-artifact: coverage-dynamo-${{ matrix.pytorch-dtype }}+ ref: ${{ inputs.ref }}++ overall:+ # Run all tests which didn't have a slow marker or are dynamo tests+ runs-on: ${{ inputs.os }}+ strategy:+ fail-fast: true+ matrix:+ pytorch-dtype: ["float32", "float64"]++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ ref: ${{ inputs.ref }}++ - name: Restore cache+ if: "${{ inputs.cache-path != '' }}"+ uses: actions/cache/restore@v4+ with:+ path: ${{ inputs.cache-path }}+ key: ${{ inputs.cache-key }}+ restore-keys: ${{ inputs.cache-restore-keys }}++ - uses: ./.github/actions/coverage+ with:+ os: ${{ inputs.os }}+ python-version: ${{ inputs.python-version }}+ pytorch-version: ${{ inputs.pytorch-version }}+ pytorch-dtype: ${{ matrix.pytorch-dtype }}+ pytorch-device: ${{ inputs.pytorch-device }}+ coverage-artifact: coverage-overall-${{ matrix.pytorch-dtype }}+ ref: ${{ inputs.ref }}++ report:+ runs-on: ${{ inputs.os }}+ needs: [slow, dynamo, overall]+ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ repository: kornia/kornia+ ref: ${{ inputs.ref }}++ - name: Download coverage reports+ uses: actions/download-artifact@v4+ with:+ merge-multiple: true++ - name: Setup python+ uses: actions/setup-python@v4+ with:+ python-version: ${{ inputs.python-version }}++ - name: Install UV+ shell: bash+ run: pip install uv++ - name: Install dev dependencies+ shell: bash+ run: uv pip install --system -r ./requirements/requirements-dev.txt++ - name: Run coverage+ run: |+ coverage combine --keep \+ $GITHUB_WORKSPACE/coverage-dynamo-float32 \+ $GITHUB_WORKSPACE/coverage-slow-float32 \+ $GITHUB_WORKSPACE/coverage-slow-float64 \+ $GITHUB_WORKSPACE/coverage-overall-float32 \+ $GITHUB_WORKSPACE/coverage-overall-float64+ coverage xml -o coverage.xml # Generate the xml+ coverage report --show-missing --skip-covered++ - if: always()+ name: Upload coverage+ uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3+ with:+ file: coverage.xml+ token: ${{ secrets.CODECOV_TOKEN }} # to not depend on build via GH API+ flags: cpu,${{ inputs.os }}_py-${{ inputs.python-version }}_pt-${{ inputs.pytorch-version }}_float32,float64+ name: cpu-coveragediff --git a/.github/workflows/docs.yml b/.github/workflows/docs.ymlnew file mode 100644index 000000000..0a373a5f6--- /dev/null+++ b/.github/workflows/docs.yml@@ -0,0 +1,128 @@+on:+ workflow_call:+ inputs:+ python-version:+ required: false+ type: string+ default: '["3.12"]'+ pytorch-version:+ required: false+ type: string+ default: '["2.5.1"]'+ os:+ required: false+ type: string+ default: ubuntu-latest+ fail-fast:+ required: false+ type: boolean+ default: false+ ref:+ required: false+ type: string+ default: ${{ github.sha }}+ cache-path:+ required: false+ type: string+ cache-key:+ required: false+ type: string+ cache-restore-keys:+ required: false+ type: string++jobs:+ test-and-build:+ name: docstests & sphinx-build - python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}+ runs-on: ubuntu-latest+ strategy:+ fail-fast: ${{ inputs.fail-fast }}+ matrix:+ python-version: ${{ fromJSON(inputs.python-version) }}+ pytorch-version: ${{ fromJSON(inputs.pytorch-version) }}+ exclude:+ # support to python3.10 only on torch 1.11 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.10"+ - pytorch-version: "1.10.2"+ python-version: "3.10"+ # support to python3.11 only on torch 2.0 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.11"+ - pytorch-version: "1.10.2"+ python-version: "3.11"+ - pytorch-version: "1.11.0"+ python-version: "3.11"+ - pytorch-version: "1.12.1"+ python-version: "3.11"+ - pytorch-version: "1.13.1"+ python-version: "3.11"+ # support to python3.12 only on torch 2.2 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.12"+ - pytorch-version: "1.10.2"+ python-version: "3.12"+ - pytorch-version: "1.11.0"+ python-version: "3.12"+ - pytorch-version: "1.12.1"+ python-version: "3.12"+ - pytorch-version: "1.13.1"+ python-version: "3.12"+ - pytorch-version: "2.0.1"+ python-version: "3.12"+ - pytorch-version: "2.1.2"+ python-version: "3.12"+ # support to python3.13 only on torch 2.5 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.13"+ - pytorch-version: "1.10.2"+ python-version: "3.13"+ - pytorch-version: "1.11.0"+ python-version: "3.13"+ - pytorch-version: "1.12.1"+ python-version: "3.13"+ - pytorch-version: "1.13.1"+ python-version: "3.13"+ - pytorch-version: "2.0.1"+ python-version: "3.13"+ - pytorch-version: "2.1.2"+ python-version: "3.13"+ - pytorch-version: "2.2.2"+ python-version: "3.13"+ - pytorch-version: "2.3.1"+ python-version: "3.13"+ - pytorch-version: "2.4.1"+ python-version: "3.13"++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ ref: ${{ inputs.ref }}++ - name: Setting environment on ${{ inputs.os }} with python ${{ matrix.python-version }} and pytorch ${{ matrix.pytorch-version }}+ uses: ./.github/actions/env+ with:+ python-version: ${{ matrix.python-version }}+ pytorch-version: ${{ matrix.pytorch-version }}+ ref: ${{ inputs.ref }}++ - name: Restore cache+ if: "${{ inputs.cache-path != '' }}"+ uses: actions/cache/restore@v4+ with:+ path: ${{ inputs.cache-path }}+ key: ${{ inputs.cache-key }}+ restore-keys: ${{ inputs.cache-restore-keys }}++ - name: Run doctest+ shell: bash -l {0}+ run: make doctest++ - name: Install docs deps+ shell: bash -l {0}+ run: uv pip install --system --editable .[docs]++ - name: Build Documentation+ shell: bash -l {0}+ run: make build-docs SPHINXOPTS="-W"diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.ymlnew file mode 100644index 000000000..88e75df6c--- /dev/null+++ b/.github/workflows/mypy.yml@@ -0,0 +1,112 @@+on:+ workflow_call:+ inputs:+ python-version:+ required: false+ type: string+ default: '["3.12"]'+ pytorch-version:+ required: false+ type: string+ default: '["2.5.1"]'+ os:+ required: false+ type: string+ default: ubuntu-latest+ fail-fast:+ required: false+ type: boolean+ default: false+ ref:+ required: false+ type: string+ default: ${{ github.sha }}++jobs:+ mypy:+ name: python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}+ runs-on: ${{ inputs.os }}+ strategy:+ fail-fast: ${{ inputs.fail-fast }}+ matrix:+ python-version: ${{ fromJSON(inputs.python-version) }}+ pytorch-version: ${{ fromJSON(inputs.pytorch-version) }}+ exclude:+ # support to python3.10 only on torch 1.11 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.10"+ - pytorch-version: "1.10.2"+ python-version: "3.10"+ # support to python3.11 only on torch 2.0 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.11"+ - pytorch-version: "1.10.2"+ python-version: "3.11"+ - pytorch-version: "1.11.0"+ python-version: "3.11"+ - pytorch-version: "1.12.1"+ python-version: "3.11"+ - pytorch-version: "1.13.1"+ python-version: "3.11"+ # support to python3.12 only on torch 2.2 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.12"+ - pytorch-version: "1.10.2"+ python-version: "3.12"+ - pytorch-version: "1.11.0"+ python-version: "3.12"+ - pytorch-version: "1.12.1"+ python-version: "3.12"+ - pytorch-version: "1.13.1"+ python-version: "3.12"+ - pytorch-version: "2.0.1"+ python-version: "3.12"+ - pytorch-version: "2.1.2"+ python-version: "3.12"+ # support to python3.13 only on torch 2.5 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.13"+ - pytorch-version: "1.10.2"+ python-version: "3.13"+ - pytorch-version: "1.11.0"+ python-version: "3.13"+ - pytorch-version: "1.12.1"+ python-version: "3.13"+ - pytorch-version: "1.13.1"+ python-version: "3.13"+ - pytorch-version: "2.0.1"+ python-version: "3.13"+ - pytorch-version: "2.1.2"+ python-version: "3.13"+ - pytorch-version: "2.2.2"+ python-version: "3.13"+ - pytorch-version: "2.3.1"+ python-version: "3.13"+ - pytorch-version: "2.4.1"+ python-version: "3.13"++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ ref: ${{ inputs.ref }}++ - name: Setting environment on ${{ inputs.os }} with python ${{ matrix.python-version }} and pytorch ${{ matrix.pytorch-version }}+ uses: ./.github/actions/env+ with:+ python-version: ${{ matrix.python-version }}+ pytorch-version: ${{ matrix.pytorch-version }}+ ref: ${{ inputs.ref }}++ - name: Run typing tests+ shell: bash -l {0}+ run: mypy kornia/++ # - if: always()+ # name: Upload typing coverage+ # uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3+ # with:+ # file: cobertura.xml+ # token: ${{ secrets.CODECOV_TOKEN }} # to not depend on build via GH API+ # flags: typing,${{ inputs.os }}_py-${{ matrix.python-version }}_pt-${{ matrix.pytorch-version }}_${{ inputs.pytorch-dtype }}+ # name: cpu-coverage-typesdiff --git a/.github/workflows/pr_test_cpu.yml b/.github/workflows/pr_test_cpu.ymlindex 3f49d494f..e282ed955 100644--- a/.github/workflows/pr_test_cpu.yml+++ b/.github/workflows/pr_test_cpu.yml@@ -13,37 +13,39 @@ concurrency:cancel-in-progress: truejobs:-pre-tests:runs-on: ubuntu-latestoutputs:hash: ${{ steps.hashid.outputs.weights-hash }}steps:- - uses: kornia/workflows/.github/actions/[email protected]- - uses: actions/cache@v4- id: cache-weights- with:- path: weights/- key: model-weights-${{ hashFiles('.github/download-models-weights.py') }}- enableCrossOsArchive: true-- - name: Download models weights...- if: steps.cache-weights.outputs.cache-hit != 'true'- run: python .github/download-models-weights.py -t weights/-- - name: write hashid- id: hashid- run: echo "weights-hash=${{ hashFiles('.github/download-models-weights.py') }}" >> "$GITHUB_OUTPUT"+ - name: Checkout repository+ uses: actions/checkout@v4++ - uses: ./.github/actions/env+ - uses: actions/cache@v4+ id: cache-weights+ with:+ path: weights/+ key: model-weights-${{ hashFiles('.github/download-models-weights.py') }}+ enableCrossOsArchive: true++ - name: Download models weights...+ if: steps.cache-weights.outputs.cache-hit != 'true'+ run: python .github/download-models-weights.py -t weights/++ - name: write hashid+ id: hashid+ run: echo "weights-hash=${{ hashFiles('.github/download-models-weights.py') }}" >> "$GITHUB_OUTPUT"tests-cpu:needs: [pre-tests]strategy:fail-fast: truematrix:- os: ['Ubuntu-latest', 'Windows-latest']- pytorch-dtype: ['float32', 'float64']+ os: ["Ubuntu-latest", "Windows-latest"]+ pytorch-dtype: ["float32", "float64"]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tests.ymlwith:os: ${{ matrix.os }}python-version: '["3.9", "3.12"]'@@ -57,21 +59,20 @@ jobs:tests-cpu-macos:needs: [pre-tests]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tests.ymlwith:- os: 'MacOS-latest'+ os: "MacOS-latest"python-version: '["3.9", "3.12"]'- pytorch-dtype: 'float32'+ pytorch-dtype: "float32"cache-path: weights/cache-key: model-weights-${{ needs.pre-tests.outputs.hash }}cache-restore-keys: |model-weights-${{ needs.pre-tests.outputs.hash }}model-weights--coverage:needs: [pre-tests]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/coverage.ymlwith:cache-path: weights/cache-key: model-weights-${{ needs.pre-tests.outputs.hash }}@@ -80,14 +81,14 @@ jobs:model-weights-typing:- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/mypy.ymltutorials:- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tutorials.ymldocs:needs: [pre-tests]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/docs.ymlwith:python-version: '["3.11"]'cache-path: weights/@@ -101,22 +102,22 @@ jobs:if: always()runs-on: ubuntu-lateststeps:- - name: check for failures- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')- run: echo job failed && exit 1+ - name: check for failures+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')+ run: echo job failed && exit 1tests-nightly:- if: contains(github.event.pull_request.labels.*.name, 'nightly')+ if: contains(github.event.pull_request.labels.*.name, 'nightly')needs: [pre-tests]name: ${{ matrix.os }} - torch-nightly, ${{ matrix.pytorch-dtype }}strategy:fail-fast: falsematrix:- os: ['Ubuntu-latest', 'Windows-latest'] #, 'MacOS-latest'] add it when https://github.com/pytorch/pytorch/pull/89262 be merged- pytorch-dtype: ['float32', 'float64']+ os: ["Ubuntu-latest", "Windows-latest"] #, 'MacOS-latest'] add it when https://github.com/pytorch/pytorch/pull/89262 be merged+ pytorch-dtype: ["float32", "float64"]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tests.ymlwith:os: ${{ matrix.os }}pytorch-version: '["nightly"]'diff --git a/.github/workflows/scheduled_test_cpu.yml b/.github/workflows/scheduled_test_cpu.ymlindex 0616b4d68..8cf4fec16 100644--- a/.github/workflows/scheduled_test_cpu.yml+++ b/.github/workflows/scheduled_test_cpu.yml@@ -17,21 +17,24 @@ jobs:outputs:hash: ${{ steps.hashid.outputs.weights-hash }}steps:- - uses: kornia/workflows/.github/actions/[email protected]- - uses: actions/cache@v4- id: cache-weights- with:- path: weights/- key: model-weights-${{ hashFiles('.github/download-models-weights.py') }}- enableCrossOsArchive: true-- - name: Download models weights...- if: steps.cache-weights.outputs.cache-hit != 'true'- run: python .github/download-models-weights.py -t weights/-- - name: write hashid- id: hashid- run: echo "weights-hash=${{ hashFiles('.github/download-models-weights.py') }}" >> "$GITHUB_OUTPUT"+ - name: Checkout repository+ uses: actions/checkout@v4++ - uses: ./.github/actions/env+ - uses: actions/cache@v4+ id: cache-weights+ with:+ path: weights/+ key: model-weights-${{ hashFiles('.github/download-models-weights.py') }}+ enableCrossOsArchive: true++ - name: Download models weights...+ if: steps.cache-weights.outputs.cache-hit != 'true'+ run: python .github/download-models-weights.py -t weights/++ - name: write hashid+ id: hashid+ run: echo "weights-hash=${{ hashFiles('.github/download-models-weights.py') }}" >> "$GITHUB_OUTPUT"tests-cpu-ubuntu:needs: [pre-tests]@@ -39,15 +42,15 @@ jobs:fail-fast: falsematrix:# os: ['Ubuntu-latest', 'Windows-latest', 'MacOS-latest']- pytorch-dtype: ['float32', 'float64']+ pytorch-dtype: ["float32", "float64"]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tests.ymlwith:- os: 'Ubuntu-latest'+ os: "Ubuntu-latest"python-version: '["3.9", "3.10", "3.11", "3.12"]'pytorch-version: '["2.0.1", "2.1.2", "2.2.2", "2.3.1", "2.4.0", "2.5.1"]'pytorch-dtype: ${{ matrix.pytorch-dtype }}- pytest-extra: '--runslow'+ pytest-extra: "--runslow"cache-path: weights/cache-key: model-weights-${{ needs.pre-tests.outputs.hash }}cache-restore-keys: |@@ -59,11 +62,11 @@ jobs:strategy:fail-fast: truematrix:- pytorch-dtype: ['float32', 'float64']+ pytorch-dtype: ["float32", "float64"]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tests.ymlwith:- os: 'Windows-latest'+ os: "Windows-latest"python-version: '["3.12"]'pytorch-version: '["2.0.1", "2.5.1"]'pytorch-dtype: ${{ matrix.pytorch-dtype }}@@ -78,11 +81,11 @@ jobs:strategy:fail-fast: truematrix:- pytorch-dtype: ['float32', 'float64']+ pytorch-dtype: ["float32", "float64"]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tests.ymlwith:- os: 'MacOS-latest'+ os: "MacOS-latest"pytorch-dtype: ${{ matrix.pytorch-dtype }}cache-path: weights/cache-key: model-weights-${{ needs.pre-tests.outputs.hash }}@@ -92,7 +95,7 @@ jobs:coverage:needs: [pre-tests]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/coverage.ymlwith:cache-path: weights/cache-key: model-weights-${{ needs.pre-tests.outputs.hash }}@@ -101,14 +104,14 @@ jobs:model-weights-typing:- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/mypy.ymltutorials:- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/tutorials.ymldocs:needs: [pre-tests]- uses: kornia/workflows/.github/workflows/[email protected]+ uses: ./.github/workflows/docs.ymlwith:python-version: '["3.11"]'cache-path: weights/diff --git a/.github/workflows/self-tests.yml b/.github/workflows/self-tests.ymlnew file mode 100644index 000000000..bec306a4d--- /dev/null+++ b/.github/workflows/self-tests.yml@@ -0,0 +1,78 @@+name: self-test++on:+ push:+ branches: [main, test-me-*]+ tags: "*"+ pull_request:++concurrency:+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}+ cancel-in-progress: true++jobs:+ env:+ strategy:+ matrix:+ os: [windows-latest, macos-latest, ubuntu-latest]+ runs-on: ${{ matrix.os }}+ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ - uses: ./.github/actions/env/+ with:+ pytorch-version: "1.9.1"+ python-version: "3.9"++ coverage:+ runs-on: ubuntu-latest+ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ - uses: ./.github/actions/coverage/++ tests:+ runs-on: ubuntu-latest+ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ - uses: ./.github/actions/tests/++ workflow-tests:+ uses: ./.github/workflows/tests.yml+ with:+ os: ubuntu-latest+ python-version: '["3.10", "3.12"]'+ pytorch-version: '["2.1.2", "2.5.1"]'+ pytorch-dtype: "float32"++ workflow-coverage:+ uses: ./.github/workflows/coverage.yml++ workflow-mypy:+ uses: ./.github/workflows/mypy.yml++ workflow-tutorials:+ uses: ./.github/workflows/tutorials.yml++ workflow-docs:+ uses: ./.github/workflows/docs.yml++ collector:+ needs:+ [+ coverage,+ env,+ tests,+ workflow-tests,+ workflow-coverage,+ workflow-mypy,+ workflow-tutorials,+ workflow-docs,+ ]+ if: always()+ runs-on: ubuntu-latest+ steps:+ - name: check for failures+ if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')+ run: echo job failed && exit 1diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlnew file mode 100644index 000000000..4b6aeed9a--- /dev/null+++ b/.github/workflows/tests.yml@@ -0,0 +1,131 @@+on:+ workflow_call:+ inputs:+ python-version:+ required: false+ type: string+ default: '["3.12"]'+ pytorch-version:+ required: false+ type: string+ default: '["2.5.1"]'+ os:+ required: false+ type: string+ default: ubuntu-latest+ pytorch-dtype:+ required: false+ type: string+ default: float32+ pytorch-device:+ required: false+ type: string+ default: cpu+ pytest-extra:+ required: false+ type: string+ default: --timeout=30 -k "not test_dynamo"+ fail-fast:+ required: false+ type: boolean+ default: false+ ref:+ required: false+ type: string+ default: ${{ github.sha }}+ cache-path:+ required: false+ type: string+ cache-key:+ required: false+ type: string+ cache-restore-keys:+ required: false+ type: string++jobs:+ tests:+ name: python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}+ runs-on: ${{ inputs.os }}+ strategy:+ fail-fast: ${{ inputs.fail-fast }}+ matrix:+ python-version: ${{ fromJSON(inputs.python-version) }}+ pytorch-version: ${{ fromJSON(inputs.pytorch-version) }}+ exclude:+ # support to python3.10 only on torch 1.11 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.10"+ - pytorch-version: "1.10.2"+ python-version: "3.10"+ # support to python3.11 only on torch 2.0 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.11"+ - pytorch-version: "1.10.2"+ python-version: "3.11"+ - pytorch-version: "1.11.0"+ python-version: "3.11"+ - pytorch-version: "1.12.1"+ python-version: "3.11"+ - pytorch-version: "1.13.1"+ python-version: "3.11"+ # support to python3.12 only on torch 2.2 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.12"+ - pytorch-version: "1.10.2"+ python-version: "3.12"+ - pytorch-version: "1.11.0"+ python-version: "3.12"+ - pytorch-version: "1.12.1"+ python-version: "3.12"+ - pytorch-version: "1.13.1"+ python-version: "3.12"+ - pytorch-version: "2.0.1"+ python-version: "3.12"+ - pytorch-version: "2.1.2"+ python-version: "3.12"+ # support to python3.13 only on torch 2.5 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.13"+ - pytorch-version: "1.10.2"+ python-version: "3.13"+ - pytorch-version: "1.11.0"+ python-version: "3.13"+ - pytorch-version: "1.12.1"+ python-version: "3.13"+ - pytorch-version: "1.13.1"+ python-version: "3.13"+ - pytorch-version: "2.0.1"+ python-version: "3.13"+ - pytorch-version: "2.1.2"+ python-version: "3.13"+ - pytorch-version: "2.2.2"+ python-version: "3.13"+ - pytorch-version: "2.3.1"+ python-version: "3.13"+ - pytorch-version: "2.4.1"+ python-version: "3.13"++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ ref: ${{ inputs.ref }}++ - name: Restore cache+ if: "${{ inputs.cache-path != '' }}"+ uses: actions/cache/restore@v4+ with:+ path: ${{ inputs.cache-path }}+ key: ${{ inputs.cache-key }}+ restore-keys: ${{ inputs.cache-restore-keys }}++ - uses: ./.github/actions/tests+ with:+ os: ${{ inputs.os }}+ python-version: ${{ matrix.python-version }}+ pytorch-version: ${{ matrix.pytorch-version }}+ pytorch-dtype: ${{ inputs.pytorch-dtype }}+ pytorch-device: ${{ inputs.pytorch-device }}+ pytest-extra: ${{ inputs.pytest-extra }}+ ref: ${{ inputs.ref }}diff --git a/.github/workflows/tutorials.yml b/.github/workflows/tutorials.ymlnew file mode 100644index 000000000..4177e580f--- /dev/null+++ b/.github/workflows/tutorials.yml@@ -0,0 +1,125 @@+on:+ workflow_call:+ inputs:+ python-version:+ required: false+ type: string+ default: '["3.12"]'+ pytorch-version:+ required: false+ type: string+ default: '["2.5.1"]'+ os:+ required: false+ type: string+ default: ubuntu-latest+ fail-fast:+ required: false+ type: boolean+ default: false+ ref:+ required: false+ type: string+ default: ${{ github.sha }}++jobs:+ run:+ name: python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}+ runs-on: ${{ inputs.os }}+ strategy:+ fail-fast: ${{ inputs.fail-fast }}+ matrix:+ python-version: ${{ fromJSON(inputs.python-version) }}+ pytorch-version: ${{ fromJSON(inputs.pytorch-version) }}+ exclude:+ # support to python3.10 only on torch 1.11 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.10"+ - pytorch-version: "1.10.2"+ python-version: "3.10"+ # support to python3.11 only on torch 2.0 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.11"+ - pytorch-version: "1.10.2"+ python-version: "3.11"+ - pytorch-version: "1.11.0"+ python-version: "3.11"+ - pytorch-version: "1.12.1"+ python-version: "3.11"+ - pytorch-version: "1.13.1"+ python-version: "3.11"+ # support to python3.12 only on torch 2.2 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.12"+ - pytorch-version: "1.10.2"+ python-version: "3.12"+ - pytorch-version: "1.11.0"+ python-version: "3.12"+ - pytorch-version: "1.12.1"+ python-version: "3.12"+ - pytorch-version: "1.13.1"+ python-version: "3.12"+ - pytorch-version: "2.0.1"+ python-version: "3.12"+ - pytorch-version: "2.1.2"+ python-version: "3.12"+ # support to python3.13 only on torch 2.5 or greater+ - pytorch-version: "1.9.1"+ python-version: "3.13"+ - pytorch-version: "1.10.2"+ python-version: "3.13"+ - pytorch-version: "1.11.0"+ python-version: "3.13"+ - pytorch-version: "1.12.1"+ python-version: "3.13"+ - pytorch-version: "1.13.1"+ python-version: "3.13"+ - pytorch-version: "2.0.1"+ python-version: "3.13"+ - pytorch-version: "2.1.2"+ python-version: "3.13"+ - pytorch-version: "2.2.2"+ python-version: "3.13"+ - pytorch-version: "2.3.1"+ python-version: "3.13"+ - pytorch-version: "2.4.1"+ python-version: "3.13"++ steps:+ - name: Checkout repository+ uses: actions/checkout@v4+ with:+ ref: ${{ inputs.ref }}++ - name: Setting environment on ${{ inputs.os }} with python ${{ matrix.python-version }} and pytorch ${{ matrix.pytorch-version }}+ uses: ./.github/actions/env+ with:+ python-version: ${{ matrix.python-version }}+ pytorch-version: ${{ matrix.pytorch-version }}+ ref: ${{ inputs.ref }}+ extra-deps: torchvision==0.20.1+cpu --find-links https://download.pytorch.org/whl/torchvision++ - uses: actions/checkout@v4+ with:+ repository: "kornia/tutorials"+ path: "tutorials-repo/"++ - name: Install dependencies+ working-directory: ./tutorials-repo/+ shell: bash -l {0}+ run: make setup++ - name: Check deps+ working-directory: ./tutorials-repo/+ shell: bash -l {0}+ run: make check-deps++ - name: Generate tutorials+ working-directory: ./tutorials-repo/+ shell: bash -l {0}+ run: make generate++ - name: Run tutorials+ working-directory: ./tutorials-repo/+ shell: bash -l {0}+ run: make executediff --git a/kornia/geometry/conversions.py b/kornia/geometry/conversions.pyindex 1b6ae3045..01a717179 100644--- a/kornia/geometry/conversions.py+++ b/kornia/geometry/conversions.py@@ -300,10 +300,10 @@ def axis_angle_to_rotation_matrix(axis_angle: Tensor) -> Tensor:Example:>>> input = tensor([[0., 0., 0.]])- >>> axis_angle_to_rotation_matrix(input)- tensor([[[1., 0., 0.],- [0., 1., 0.],- [0., 0., 1.]]])+ >>> axis_angle_to_rotation_matrix(input) # doctest: +ELLIPSIS+ tensor([[[1., ...0., 0.],+ [0., 1., ...0.],+ [...0., 0., 1.]]])>>> input = tensor([[1.5708, 0., 0.]])>>> axis_angle_to_rotation_matrix(input)