Python wrapper for Nvidia CUDA parallel computation API with object cleanup, automatic error checking, and convenient abstractions.
Implement a GPU-accelerated image sampler that applies different edge-handling strategies when sampling pixels outside image boundaries. Your implementation should support multiple addressing modes (wrap, clamp, border) and interpolation methods (nearest-neighbor and bilinear).
When processing images on the GPU, it's often necessary to sample pixel values at arbitrary coordinates, including positions outside the image boundaries. Different applications require different behaviors at these edges:
Additionally, sampling at non-integer coordinates requires interpolation between neighboring pixels using either nearest-neighbor (fast) or bilinear interpolation (smooth).
Your implementation must:
image_sampler.py: Main implementationtest_image_sampler.py: Test casesProvides GPU computation capabilities for accelerated image sampling.
The following test cases should be implemented:
Input:
[[0.0, 0.25, 0.5, 0.75],
[0.1, 0.35, 0.6, 0.85],
[0.2, 0.45, 0.7, 0.95],
[0.3, 0.55, 0.8, 1.0]][[-0.1, 0.1], [1.1, 0.5], [0.5, -0.2]] (normalized)Expected Output:
Array: [0.75, 0.2, 0.95]
Input:
[[0.0, 0.5, 1.0],
[0.2, 0.5, 0.8],
[0.4, 0.5, 0.6]][[0.5, 0.5], [1.2, 0.5], [0.5, -0.1]] (normalized)Expected Output:
Values will vary based on interpolation, but should reflect edge clamping behavior.
Input:
[[0.0, 1.0],
[1.0, 0.0]][[-0.5, 0.5], [1.5, 0.5], [0.5, 0.5]] (normalized)Expected Output:
Array: [0.5, 0.5, <interpolated value>]
tessl i tessl/pypi-pycuda@2025.1.0docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10