arrayfire / arrayfire-binary-python-wrapper

A python thin wrapper for ArrayFire library
https://arrayfire.com
BSD 3-Clause "New" or "Revised" License
2 stars 5 forks source link

Forward and Gradient-Based Convolution Testing #43

Closed AzeezIsh closed 5 months ago

AzeezIsh commented 5 months ago

This PR introduces a suite of unit tests for convolutions.py located within the within the machine learning and signal processing directories. The primary functions in this file involve neural network convolutions, FFT convolutions, gradient convolutions, and different dimension-based convolutions.

Convolution Operations with Varying Input Shapes Convolve2 and Convolve3 Operations: Convolution operations return the correct output shape for various input matrix sizes, ensuring that both 2D and 3D convolutions handle input dimensions as expected. Edge Cases: Includes tests for very small input matrices (e.g., 1x1) and scenarios where kernel sizes are large relative to the input, checking for correct handling of these edge cases. Data Type Handling Support for Multiple Data Types: Floating-point precision variants (16-bit, 32-bit, 64-bit) are tested to ensure convolutions work correctly across different numerical representations. Invalid Data Types: Tests ensure that attempting convolution operations with unsupported data types (e.g., integers, complex numbers) correctly raises errors, preventing undefined behavior. Convolution Parameters Variability Strides, Padding, Dilation: Parameterized tests cover various configurations of strides, padding, and dilation, verifying that the output shapes match expected values for each configuration. Kernel Size Variations: Tests with different kernel sizes confirm that the convolution output adjusts appropriately, ensuring flexibility in convolution kernel selection. Convolution Modes and Domains Different Convolution Modes: The effect of changing convolution modes (e.g., default, expand) on the output size and behavior is thoroughly tested. Convolution Domains: Testing across different convolution domains (e.g., spatial, frequency) to validate that the library correctly implements domain-specific convolution logic. Gradient Computations Convolution Gradients: Includes tests for gradient computation through convolutions, covering various gradient types (e.g., filter, data, bias gradients) and ensuring gradients are computed correctly with respect to input data. Error Handling and Robustness Invalid Configurations: Checks for negative padding, strides, or dilation sizes, ensuring the library robustly handles invalid inputs by raising exceptions. Complex Number Handling: Explicit tests for operations involving complex numbers, assessing the library's support for complex convolution operations.