tessl install tessl/pypi-cupy-cuda101@9.6.0CuPy: NumPy & SciPy for GPU (CUDA 10.1 version)
Agent Success
Agent success rate when using this tile
87%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.19x
Baseline
Agent success rate without this tile
73%
Implement a system that prepares arrays of different shapes for batch operations by ensuring they are all compatible for element-wise operations. The system should handle arrays with different dimensionalities and broadcast them to a common shape.
Implement a function broadcast_arrays_to_common_shape(arrays) that:
Implement a function expand_to_shape(array, target_shape) that:
GPU-accelerated array library with NumPy-compatible API for numerical computing.
File: test_shape_normalizer.py
Description: Test basic broadcasting with two arrays
Input:
import cupy as cp
from shape_normalizer import broadcast_arrays_to_common_shape
arrays = [
cp.array([1, 2, 3]),
cp.array([[4], [5], [6]])
]
result = broadcast_arrays_to_common_shape(arrays)Expected Output: All arrays in result should have shape (3, 3). The first array is broadcast from (3,) to (3, 3), and the second array is broadcast from (3, 1) to (3, 3).
File: test_shape_normalizer.py
Description: Test expanding a single array to a target shape
Input:
import cupy as cp
from shape_normalizer import expand_to_shape
arr = cp.array([1, 2, 3])
result = expand_to_shape(arr, (4, 3))Expected Output: Result shape should be (4, 3) with the original array values repeated along the first axis.
shape_normalizer.py - Main implementation filetest_shape_normalizer.py - Test file with the test cases above