From 35074ea95923be1aac78644ecdc0bf62d13c33aa Mon Sep 17 00:00:00 2001 From: Jinguo Liu Date: Fri, 25 Apr 2025 14:58:28 +0800 Subject: [PATCH 1/2] Update construction.jl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following issue: https://github.com/ArrogantGao/benchmark_tropical_tensornetwork/issues/1 After fix, it has 20x speed up on high dimensional arrays: ```julia julia> @btime CUDA.@sync fill!($(CUDA.zeros(TropicalF32, fill(2, 20)...)), zero(TropicalF32)); 15.316 μs (57 allocations: 1.52 KiB) ``` --- src/host/construction.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/host/construction.jl b/src/host/construction.jl index b3d6071fa..886f652bf 100644 --- a/src/host/construction.jl +++ b/src/host/construction.jl @@ -19,7 +19,7 @@ function Base.fill!(A::AnyGPUArray{T}, x) where T # ndims check for 0D support kernel = fill_kernel!(get_backend(A)) - kernel(A, x; ndrange = ndims(A) > 0 ? size(A) : (1,)) + kernel(A, x; ndrange = ndims(A) > 0 ? length(A) : (1,)) A end From a7deabc96774f72104f20def043d45ca96a6fa08 Mon Sep 17 00:00:00 2001 From: Jinguo Liu Date: Fri, 25 Apr 2025 15:02:12 +0800 Subject: [PATCH 2/2] Update construction.jl --- src/host/construction.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/host/construction.jl b/src/host/construction.jl index 886f652bf..1a4d8f7b5 100644 --- a/src/host/construction.jl +++ b/src/host/construction.jl @@ -19,7 +19,7 @@ function Base.fill!(A::AnyGPUArray{T}, x) where T # ndims check for 0D support kernel = fill_kernel!(get_backend(A)) - kernel(A, x; ndrange = ndims(A) > 0 ? length(A) : (1,)) + kernel(A, x; ndrange = length(A)) A end