From 5e3b080ab33a99c7ef4c72eef040b3895e9eaaa3 Mon Sep 17 00:00:00 2001 From: Yueh-Hua Tu Date: Thu, 15 Apr 2021 00:49:11 +0800 Subject: [PATCH 1/2] avoiding scalar indexing in cuda --- src/utils.jl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index eec6d3d4d..607c68fca 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -12,7 +12,4 @@ Return the maximum value for each dimension. An array of dimensions `dims` is ac The maximum of each dimension in the element is computed. """ maximum_dims(dims::AbstractArray{<:Integer}) = (maximum(dims), ) - -function maximum_dims(dims::AbstractArray{<:Tuple}) - Tuple(maximum(xs) for xs in zip(dims...)) -end +maximum_dims(dims::AbstractArray{NTuple{N, T}}) where {N,T} = Tuple(maximum(x->x[i], dims) for i = 1:N) From 63b6b64ba097b281e3e2758c73f1a0ba1b29d971 Mon Sep 17 00:00:00 2001 From: Dhairya Gandhi Date: Thu, 15 Apr 2021 12:40:05 +0530 Subject: [PATCH 2/2] use ntuple instead Co-authored-by: Carlo Lucibello --- src/utils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index 607c68fca..e5bc9e5af 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -12,4 +12,4 @@ Return the maximum value for each dimension. An array of dimensions `dims` is ac The maximum of each dimension in the element is computed. """ maximum_dims(dims::AbstractArray{<:Integer}) = (maximum(dims), ) -maximum_dims(dims::AbstractArray{NTuple{N, T}}) where {N,T} = Tuple(maximum(x->x[i], dims) for i = 1:N) +maximum_dims(dims::AbstractArray{NTuple{N, T}}) where {N,T} = ntuple(i -> maximum(x->x[i], dims), N)