Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Introduces `benchmarks/` (#2777)

João Gustavo A. Amorim9577aef5db04
diff --git a/benchmarks/color/gray_test.py b/benchmarks/color/gray_test.py
new file mode 100644
index 000000000..03f7e0598
--- /dev/null
+++ b/benchmarks/color/gray_test.py
@@ -0,0 +1,30 @@
+import pytest
+import torch
+
+from kornia.color import grayscale_to_rgb
+
+
[email protected]("B", [1, 5])
[email protected]("H", [128, 237, 512])
[email protected]("W", [128, 237, 512])
+def test_grayscale_to_rgb(benchmark, device, dtype, B, C, H, W):
+ data = torch.rand(B, C, H, W, device=device, dtype=dtype)
+
+ actual = benchmark(grayscale_to_rgb, image=data)
+
+ assert actual.shape == (B, 3, H, W)
+
+
[email protected]("B", [1, 5])
[email protected]("H", [128, 237, 512])
[email protected]("W", [128, 237, 512])
+def test_grayscale_to_rgb_compile(benchmark, device, dtype, torch_optimizer, B, C, H, W):
+ data = torch.rand(B, C, H, W, device=device, dtype=dtype)
+
+ op = torch_optimizer(grayscale_to_rgb)
+
+ actual = benchmark(op, image=data)
+
+ assert actual.shape == (B, 3, H, W)
diff --git a/pyproject.toml b/pyproject.toml
index 5744d61f0..521a548b4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -166,6 +166,7 @@ requires = [
"docs/generate_examples.py" = ["C901"] # Allow too complex function
"kornia/__init__.py" = ["I001"] # Allow unsorted imports
"tests/*" = ["S101", "S311", "BLE", "RUF012", "RUF005"] # allow assert, random, ignore BLE, mutable class attr
+ "benchmarks/*" = ["S101", "S311", "BLE", "RUF012", "RUF005"] # allow assert, random, ignore BLE, mutable class attr
"testing/*" = ["S101",] # allow assert
[tool.pytest.ini_options]
diff --git a/requirements/requirements-benchmarks.txt b/requirements/requirements-benchmarks.txt
new file mode 100644
index 000000000..ad5b81618
--- /dev/null
+++ b/requirements/requirements-benchmarks.txt
@@ -0,0 +1 @@
+pytest-benchmark