Repository: kornia/kornia

Issue:
Update `make test-all`
```Makefile
# TODO: Add cuda-float16 when #649 is solved
test-all: FORCE
	pytest -v --device all --dtype float32,float64 --cov=kornia test/ --flake8 --mypy
```
Maybe instead of just adding `float16`, we can use `--dtype all`? (https://github.com/kornia/kornia/blob/5d1d8cc8c4fb3e398b429edd2cc25ef40d6299ce/conftest.py#L77)


Discussion:
sure -- as side note not very clear we use this command at all since every setup is different.
Personally, I think `make` unnecessary here, and sometimes it gets outdated (but it's not my project 😅 -- so I didn't go deep and suggest removing this)

For me, it seems better to explain in `contributing.md` how we should perform the tests and options than to have the `Makefile`. 
well i use very often `make lint` `make mypy` -- other than that i use the following workflow
 `pytest test/dev_file.py::ClassDev::test_dev --device=[first cpu/later cuda] --dtype=float32/float64`

happy to update whatever is easier for everyone @ducha-aiki 
I also use `make lint` `make mypy` and `make test-mps`, `make test-cpu`. Not used `make all` for a long time.
Regarding `contributing.md` - well, usually noone reads it anyway :)
> Regarding `contributing.md` - well, usually noone reads it anyway :)

Maybe because it has to be polished ? If anyone has some time to go for it, do not hesitate to give it a shot

Resolving patch:
diff --git a/kornia/enhance/core.py b/kornia/enhance/core.py
--- a/kornia/enhance/core.py
+++ b/kornia/enhance/core.py
@@ -1,8 +1,12 @@
-from kornia.core import Module, Tensor
+from typing import Union
+
+from kornia.core import Module, Tensor, tensor
 from kornia.testing import KORNIA_CHECK, KORNIA_CHECK_IS_TENSOR
 
 
-def add_weighted(src1: Tensor, alpha, src2: Tensor, beta, gamma) -> Tensor:
+def add_weighted(
+    src1: Tensor, alpha: Union[float, Tensor], src2: Tensor, beta: Union[float, Tensor], gamma: Union[float, Tensor]
+) -> Tensor:
     r"""Calculate the weighted sum of two Tensors.
 
     .. image:: _static/img/add_weighted.png
@@ -35,12 +39,21 @@ def add_weighted(src1: Tensor, alpha, src2: Tensor, beta, gamma) -> Tensor:
     KORNIA_CHECK_IS_TENSOR(src1)
     KORNIA_CHECK_IS_TENSOR(src2)
     KORNIA_CHECK(src1.shape == src2.shape, f"src1 and src2 have different shapes. Got {src1.shape} and {src2.shape}")
+
     if isinstance(alpha, Tensor):
         KORNIA_CHECK(src1.shape == alpha.shape, "alpha has a different shape than src.")
+    else:
+        alpha = tensor(alpha, dtype=src1.dtype, device=src1.device)
+
     if isinstance(beta, Tensor):
         KORNIA_CHECK(src1.shape == beta.shape, "beta has a different shape than src.")
+    else:
+        beta = tensor(beta, dtype=src1.dtype, device=src1.device)
+
     if isinstance(gamma, Tensor):
         KORNIA_CHECK(src1.shape == gamma.shape, "gamma has a different shape than src.")
+    else:
+        gamma = tensor(gamma, dtype=src1.dtype, device=src1.device)
 
     return src1 * alpha + src2 * beta + gamma
 


Test patch:
diff --git a/.github/workflows/pr_test_cpu.yml b/.github/workflows/pr_test_cpu.yml
new file mode 100644
--- /dev/null
+++ b/.github/workflows/pr_test_cpu.yml
@@ -0,0 +1,46 @@
+name: Run tests on CPU
+
+on:
+  pull_request:
+    branches: [master]
+    types: [open, reopened, synchronize, review_requested, ready_for_review]
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  tests-cpu:
+    name: ${{ matrix.os }} - python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}, ${{ matrix.pytorch-dtype }}
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      fail-fast: true
+      matrix:
+        os: [ubuntu-latest, windows-latest, macos]
+        python-version: ['3.7', '3.8']
+        pytorch-version: ['1.9.1', '1.12.1']
+        pytorch-dtype: ['float16', 'float32', 'float64']
+
+    steps:
+      - name: Checkout kornia
+        uses: actions/checkout@v3
+
+      - name: Setting environment on ${{ matrix.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 }}
+
+      - name: Run CPU tests ${{ matrix.pytorch-dtype }}
+        continue-on-error: ${{ contains('float16', matrix.pytorch-dtype) }}  # Remove this when float16 stop raising errors
+        shell: bash -l {0}
+        run: pytest -v --device cpu --dtype ${{ matrix.pytorch-dtype }} --cov=kornia --cov-report xml ./test
+
+      - if: always()
+        name: Upload coverage
+        uses: codecov/codecov-action@v3
+        with:
+          file: coverage.xml
+          flags: cpu,${{ matrix.os }}_python-${{ matrix.python-version }}_torch-${{ matrix.pytorch-version }}_${{ matrix.pytorch-dtype }}
+          name: cpu-coverage
diff --git a/.github/workflows/pr_test_typing.yml b/.github/workflows/pr_test_typing.yml
new file mode 100644
--- /dev/null
+++ b/.github/workflows/pr_test_typing.yml
@@ -0,0 +1,44 @@
+name: Run typing tests
+
+on:
+  pull_request:
+    branches: [master]
+    types: [open, reopened, synchronize, review_requested, ready_for_review]
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  tests:
+    name: ${{ matrix.os }} - python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest]
+        python-version: ['3.7']
+        pytorch-version: ['1.9.1', '1.12.1']
+
+    steps:
+      - name: Checkout kornia
+        uses: actions/checkout@v3
+
+      - name: Setting environment on ${{ matrix.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 }}
+
+      - name: Run typing tests
+        shell: bash -l {0}
+        run: mypy --cobertura-xml-report ./
+
+      - if: always()
+        name: Upload coverage
+        uses: codecov/codecov-action@v3
+        with:
+          file: cobertura.xml
+          flags: typing,${{ matrix.os }}_python-${{ matrix.python-version }}_torch-${{ matrix.pytorch-version }}
+          name: cpu-coverage-types
diff --git a/.github/workflows/scheduled_test_cpu.yml b/.github/workflows/scheduled_test_cpu.yml
new file mode 100644
--- /dev/null
+++ b/.github/workflows/scheduled_test_cpu.yml
@@ -0,0 +1,47 @@
+name: (scheduled) Run tests on CPU
+
+on:
+  push:
+    branches: [master]
+  schedule:
+    - cron: "0 4 * * *"
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  tests-cpu:
+    name: ${{ matrix.os }} - python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}, ${{ matrix.pytorch-dtype }}
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest, windows-latest, macos]
+        python-version: ['3.7', '3.8']
+        pytorch-version: ['1.9.1', '1.10.2', '1.12.1', '1.13.0', 'nightly']
+        pytorch-dtype: ['float16', 'float32', 'float64']
+
+    steps:
+      - name: Checkout kornia
+        uses: actions/checkout@v3
+
+      - name: Setting environment on ${{ matrix.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 }}
+
+      - name: Run CPU tests ${{ matrix.pytorch-dtype }}
+        shell: bash -l {0}
+        run: pytest -v --device cpu --dtype ${{ matrix.pytorch-dtype }} --cov=kornia --cov-report xml ./test
+
+
+      - if: always()
+        name: Upload coverage
+        uses: codecov/codecov-action@v3
+        with:
+          file: coverage.xml
+          flags: cpu,${{ matrix.os }}_python-${{ matrix.python-version }}_torch-${{ matrix.pytorch-version }}_${{ matrix.pytorch-dtype }}
+          name: cpu-coverage
diff --git a/.github/workflows/scheduled_test_typing.yml b/.github/workflows/scheduled_test_typing.yml
new file mode 100644
--- /dev/null
+++ b/.github/workflows/scheduled_test_typing.yml
@@ -0,0 +1,45 @@
+name: (scheduled) Run typing tests
+
+on:
+  push:
+    branches: [master]
+  schedule:
+    - cron: "0 4 * * *"
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  tests:
+    name: ${{ matrix.os }} - python-${{ matrix.python-version }}, torch-${{ matrix.pytorch-version }}
+    runs-on: ${{ matrix.os }}
+
+    strategy:
+      fail-fast: false
+      matrix:
+        os: [ubuntu-latest]
+        python-version: ['3.7']
+        pytorch-version: ['1.9.1', '1.10.2', '1.12.1', '1.13.0', 'nightly']
+
+    steps:
+      - name: Checkout kornia
+        uses: actions/checkout@v3
+
+      - name: Setting environment on ${{ matrix.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 }}
+
+      - name: Run typing tests
+        shell: bash -l {0}
+        run: mypy --cobertura-xml-report ./
+
+      - if: always()
+        name: Upload coverage
+        uses: codecov/codecov-action@v3
+        with:
+          file: cobertura.xml
+          flags: typing,${{ matrix.os }}_python-${{ matrix.python-version }}_torch-${{ matrix.pytorch-version }}
+          name: cpu-coverage-types
diff --git a/.github/workflows/test_typing.yml b/.github/workflows/test_typing.yml
deleted file mode 100644
--- a/.github/workflows/test_typing.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-name: test-typing
-
-on:
-  push:
-    branches: [master]
-  pull_request:
-    branches: [master]
-    types: [open, reopened, synchronize, review_requested, ready_for_review]
-  schedule:
-    - cron: "0 4 * * *"
-
-concurrency:
-  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
-  cancel-in-progress: true
-
-jobs:
-  tests-cpu:
-    runs-on: ${{ matrix.os }}
-    strategy:
-      fail-fast: false
-      matrix:
-        os: [ubuntu-latest]
-        python-version: [3.8]
-    steps:
-    - uses: actions/checkout@v2
-    - name: Setup conda dependencies
-      uses: conda-incubator/setup-miniconda@v2
-      with:
-        auto-update-conda: true
-        python-version: ${{ matrix.python-version }}
-    - name: Install dependencies
-      shell: bash -l {0}
-      run: |
-        conda install curl -c conda-forge
-        conda install pytorch cpuonly -c pytorch-lts
-        pip install .[dev,x]
-    - name: Run Tests
-      shell: bash -l {0}
-      run: pytest -v --cov=kornia --cov-report xml --mypy kornia/
-    - name: Upload coverage
-      uses: codecov/codecov-action@v1
-      with:
-        token: ${{ secrets.CODECOV_TOKEN }}
-        file: coverage.xml
-        flags: cpu,pytest,typing
-        name: cpu-coverage
diff --git a/.github/workflows/tests_cpu.yml b/.github/workflows/tests_cpu.yml
deleted file mode 100644
--- a/.github/workflows/tests_cpu.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-name: tests-cpu
-
-on:
-  push:
-    branches: [master]
-  pull_request:
-    branches: [master]
-    types: [open, reopened, synchronize, review_requested, ready_for_review]
-  schedule:
-    - cron: "0 4 * * *"
-
-concurrency:
-  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
-  cancel-in-progress: true
-
-jobs:
-  tests-cpu:
-    runs-on: ${{ matrix.os }}
-    strategy:
-      fail-fast: false
-      matrix:
-        os: [ubuntu-latest, macos-latest, windows-latest]
-        python-version: [3.7, 3.8, 3.9]
-        pytorch-version: [1.10.2, 1.12.1]
-    steps:
-    - uses: actions/checkout@v2
-    - name: Setup conda dependencies
-      uses: conda-incubator/setup-miniconda@v2
-      with:
-        auto-update-conda: true
-        python-version: ${{ matrix.python-version }}
-    - name: Install dependencies
-      shell: bash -l {0}
-      run: |
-        conda install curl -c conda-forge
-        conda install pytorch=${{ matrix.pytorch-version }} cpuonly -c pytorch
-        pip install .[dev,x]
-    - name: Run Tests
-      shell: bash -l {0}
-      run: pytest -v --device cpu --dtype float32,float64 --cov=kornia --cov-report xml ./test
-    - name: Upload coverage
-      uses: codecov/codecov-action@v1
-      with:
-        token: ${{ secrets.CODECOV_TOKEN }}
-        file: coverage.xml
-        flags: cpu,pytest, torch${{ matrix.pytorch-version }}
-        name: cpu-coverage
diff --git a/.github/workflows/tests_lts.yml b/.github/workflows/tests_lts.yml
deleted file mode 100644
--- a/.github/workflows/tests_lts.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-name: tests-lts
-
-on:
-  push:
-    branches: [master]
-  pull_request:
-    branches: [master]
-    types: [open, reopened, synchronize, review_requested, ready_for_review]
-  schedule:
-    - cron: "0 4 * * *"
-
-concurrency:
-  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
-  cancel-in-progress: true
-
-jobs:
-  tests-cpu:
-    runs-on: ${{ matrix.os }}
-    strategy:
-      fail-fast: false
-      matrix:
-        os: [ubuntu-latest, windows-latest]
-        python-version: [3.7, 3.8]
-    steps:
-    - uses: actions/checkout@v2
-    - name: Setup conda dependencies
-      uses: conda-incubator/setup-miniconda@v2
-      with:
-        auto-update-conda: true
-        python-version: ${{ matrix.python-version }}
-    - name: Install dependencies
-      shell: bash -l {0}
-      run: |
-        conda install curl -c conda-forge
-        conda install pytorch cpuonly -c pytorch-lts
-        pip install .[dev,x]
-    - name: Run Tests
-      shell: bash -l {0}
-      run: pytest -v --device cpu --dtype float32,float64 --cov=kornia --cov-report xml ./test
-    - name: Upload coverage
-      uses: codecov/codecov-action@v1
-      with:
-        token: ${{ secrets.CODECOV_TOKEN }}
-        file: coverage.xml
-        flags: cpu,pytest,torch-lts-1.8.2
-        name: cpu-coverage
diff --git a/.github/workflows/tests_nightly.yml b/.github/workflows/tests_nightly.yml
deleted file mode 100644
--- a/.github/workflows/tests_nightly.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-name: test-nightly
-
-on:
-  #push:
-  #  branches:
-  #    - master
-  #pull_request:
-  schedule:
-    - cron: "0 4 * * *"
-
-jobs:
-  test-cpu-versions:
-    runs-on: ${{ matrix.os }}
-    strategy:
-      fail-fast: false
-      matrix:
-        os: [ubuntu-latest, macos-latest, windows-latest]
-        python-version: [3.7, 3.8]
-    steps:
-    - uses: actions/checkout@v2
-    - name: Setup conda dependencies
-      uses: conda-incubator/setup-miniconda@v2
-      with:
-        auto-update-conda: true
-        python-version: ${{ matrix.python-version }}
-    - name: Install dependencies
-      shell: bash -l {0}
-      run: |
-        conda install curl -c conda-forge
-        conda install pytorch cpuonly -c pytorch-nightly
-        pip install .[dev,x]
-    - name: Run Tests
-      shell: bash -l {0}
-      run: pytest -v --device cpu --dtype float32,float64 ./test