From 3ea27dbd166991b2ade4cb67587c68f63fc7df6c Mon Sep 17 00:00:00 2001 From: Abhirath Anand <74202102+theabhirath@users.noreply.github.com> Date: Wed, 2 Mar 2022 08:03:20 +0530 Subject: [PATCH 01/10] Changed libblas to libblastrampoline --- src/gemm.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gemm.jl b/src/gemm.jl index 6db7ccaac..9dbf1661a 100644 --- a/src/gemm.jl +++ b/src/gemm.jl @@ -2,7 +2,7 @@ ## Borrowed from Knet.jl, adapted for compile-time constants using LinearAlgebra -using LinearAlgebra.BLAS: libblas, BlasInt, @blasfunc +using LinearAlgebra.BLAS: libblastrampoline, BlasInt, @blasfunc using Compat: get_num_threads, set_num_threads # needs Compat 3.13, for any Julia < 1.6 @@ -48,7 +48,7 @@ for (gemm, elt) in gemm_datatype_mappings ldb = N end ldc = M - ccall((@blasfunc($(gemm)), libblas), Nothing, + ccall((@blasfunc($(gemm)), libblastrampoline), Nothing, (Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, Ref{BlasInt}, Ptr{$elt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, @@ -106,7 +106,7 @@ for (gemm, elt) in gemm_datatype_mappings ptrBk = ptrB + (k-1) * strB * sizeof($elt) ptrCk = ptrC + (k-1) * strC * sizeof($elt) - ccall((@blasfunc($(gemm)), libblas), Nothing, + ccall((@blasfunc($(gemm)), libblastrampoline), Nothing, (Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, Ref{BlasInt}, Ptr{$elt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, @@ -128,7 +128,7 @@ for (gemm, elt) in gemm_datatype_mappings ptrBk = ptrB + (k-1) * strB * sizeof($elt) ptrCk = ptrC + (k-1) * strC * sizeof($elt) - ccall((@blasfunc($(gemm)), libblas), Nothing, + ccall((@blasfunc($(gemm)), libblastrampoline), Nothing, (Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, Ref{BlasInt}, Ptr{$elt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, From 773d8ee9a1ef19774b15426190ba4c6619fce376 Mon Sep 17 00:00:00 2001 From: Abhirath Anand <74202102+theabhirath@users.noreply.github.com> Date: Wed, 2 Mar 2022 08:32:58 +0530 Subject: [PATCH 02/10] Fix for Julia v1.6 --- src/gemm.jl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gemm.jl b/src/gemm.jl index 9dbf1661a..6d165ced1 100644 --- a/src/gemm.jl +++ b/src/gemm.jl @@ -2,7 +2,14 @@ ## Borrowed from Knet.jl, adapted for compile-time constants using LinearAlgebra -using LinearAlgebra.BLAS: libblastrampoline, BlasInt, @blasfunc +using LinearAlgebra.BLAS: BlasInt, @blasfunc + +if VERSION >= v"1.7-" + using LinearAlgebra.BLAS: libblastrampoline + libblas = libblastrampoline +else + using LinearAlgebra.BLAS: libblas +end using Compat: get_num_threads, set_num_threads # needs Compat 3.13, for any Julia < 1.6 @@ -48,7 +55,7 @@ for (gemm, elt) in gemm_datatype_mappings ldb = N end ldc = M - ccall((@blasfunc($(gemm)), libblastrampoline), Nothing, + ccall((@blasfunc($(gemm)), libblas), Nothing, (Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, Ref{BlasInt}, Ptr{$elt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, @@ -106,7 +113,7 @@ for (gemm, elt) in gemm_datatype_mappings ptrBk = ptrB + (k-1) * strB * sizeof($elt) ptrCk = ptrC + (k-1) * strC * sizeof($elt) - ccall((@blasfunc($(gemm)), libblastrampoline), Nothing, + ccall((@blasfunc($(gemm)), libblas), Nothing, (Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, Ref{BlasInt}, Ptr{$elt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, @@ -128,7 +135,7 @@ for (gemm, elt) in gemm_datatype_mappings ptrBk = ptrB + (k-1) * strB * sizeof($elt) ptrCk = ptrC + (k-1) * strC * sizeof($elt) - ccall((@blasfunc($(gemm)), libblastrampoline), Nothing, + ccall((@blasfunc($(gemm)), libblas), Nothing, (Ref{UInt8}, Ref{UInt8}, Ref{BlasInt}, Ref{BlasInt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, Ref{BlasInt}, Ptr{$elt}, Ref{BlasInt}, Ref{$elt}, Ptr{$elt}, From 1d7a7edd7677d12419df83d8c6aefb05872abe80 Mon Sep 17 00:00:00 2001 From: Abhirath Anand <74202102+theabhirath@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:09:37 +0530 Subject: [PATCH 03/10] use const --- src/gemm.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gemm.jl b/src/gemm.jl index 6d165ced1..0472fbe7b 100644 --- a/src/gemm.jl +++ b/src/gemm.jl @@ -6,7 +6,7 @@ using LinearAlgebra.BLAS: BlasInt, @blasfunc if VERSION >= v"1.7-" using LinearAlgebra.BLAS: libblastrampoline - libblas = libblastrampoline + const libblas = libblastrampoline else using LinearAlgebra.BLAS: libblas end From 333fb7891773ddfa0fc018781c2af96e8633b554 Mon Sep 17 00:00:00 2001 From: Abhirath Anand <74202102+theabhirath@users.noreply.github.com> Date: Thu, 3 Mar 2022 22:38:07 +0530 Subject: [PATCH 04/10] Update src/gemm.jl Co-authored-by: Ian Butterworth --- src/gemm.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gemm.jl b/src/gemm.jl index 0472fbe7b..3fdfeca3b 100644 --- a/src/gemm.jl +++ b/src/gemm.jl @@ -4,7 +4,7 @@ using LinearAlgebra using LinearAlgebra.BLAS: BlasInt, @blasfunc -if VERSION >= v"1.7-" +@static if VERSION >= v"1.7-" using LinearAlgebra.BLAS: libblastrampoline const libblas = libblastrampoline else From 53925ec9b6c21912eeb4e23d1f4214b139911307 Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Thu, 3 Mar 2022 13:38:19 -0500 Subject: [PATCH 05/10] Update gemm.jl --- src/gemm.jl | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gemm.jl b/src/gemm.jl index 6ff2178eb..7d2f61755 100644 --- a/src/gemm.jl +++ b/src/gemm.jl @@ -4,12 +4,7 @@ using LinearAlgebra using LinearAlgebra.BLAS: BlasInt, @blasfunc -@static if VERSION >= v"1.7-" - using LinearAlgebra.BLAS: libblastrampoline - const libblas = libblastrampoline -else - using LinearAlgebra.BLAS: libblas -end +const libblas = Base.libblas_name using Compat: get_num_threads, set_num_threads # needs Compat 3.13, for any Julia < 1.6 From 90564dcbc64083be4bd306707dcc73681aee7dcb Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Thu, 3 Mar 2022 14:03:17 -0500 Subject: [PATCH 06/10] Update NNlib.jl --- src/NNlib.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NNlib.jl b/src/NNlib.jl index 182d00faa..c2dfc6925 100644 --- a/src/NNlib.jl +++ b/src/NNlib.jl @@ -10,7 +10,9 @@ using Statistics using Statistics: mean using LinearAlgebra using LinearAlgebra: BlasFloat, Transpose, Adjoint, AdjOrTransAbsMat -using LinearAlgebra.BLAS: libblas, BlasInt, @blasfunc +using LinearAlgebra.BLAS: BlasInt, @blasfunc + +const libblas = Base.libblas_name const IntOrIntTuple = Union{Integer, NTuple{N,<:Integer} where N} const Numeric = Union{AbstractArray{<:T}, T} where {T<:Number} From c0836607461146ebc2cba426f382e5325e933078 Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Thu, 3 Mar 2022 14:03:37 -0500 Subject: [PATCH 07/10] Create gemm.jl --- src/gemm.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/gemm.jl b/src/gemm.jl index 7d2f61755..bfac30638 100644 --- a/src/gemm.jl +++ b/src/gemm.jl @@ -4,8 +4,6 @@ using LinearAlgebra using LinearAlgebra.BLAS: BlasInt, @blasfunc -const libblas = Base.libblas_name - using Compat: get_num_threads, set_num_threads # needs Compat 3.13, for any Julia < 1.6 """ From 5680797415b6d946e3c832dbea8ab7b5e4a16d95 Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Thu, 3 Mar 2022 14:04:15 -0500 Subject: [PATCH 08/10] Update gemm.jl --- src/gemm.jl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gemm.jl b/src/gemm.jl index bfac30638..10cb49f62 100644 --- a/src/gemm.jl +++ b/src/gemm.jl @@ -1,9 +1,6 @@ ## Low level gemm! call with pointers ## Borrowed from Knet.jl, adapted for compile-time constants -using LinearAlgebra -using LinearAlgebra.BLAS: BlasInt, @blasfunc - using Compat: get_num_threads, set_num_threads # needs Compat 3.13, for any Julia < 1.6 """ From d5e4d979a170a9bdc26242b0d5e6b9f8af2fc1d5 Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Thu, 3 Mar 2022 14:10:33 -0500 Subject: [PATCH 09/10] Update NNlib.jl --- src/NNlib.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NNlib.jl b/src/NNlib.jl index c2dfc6925..47de37d32 100644 --- a/src/NNlib.jl +++ b/src/NNlib.jl @@ -12,7 +12,7 @@ using LinearAlgebra using LinearAlgebra: BlasFloat, Transpose, Adjoint, AdjOrTransAbsMat using LinearAlgebra.BLAS: BlasInt, @blasfunc -const libblas = Base.libblas_name +const libblas = "libblastrampoline" const IntOrIntTuple = Union{Integer, NTuple{N,<:Integer} where N} const Numeric = Union{AbstractArray{<:T}, T} where {T<:Number} From 19372ca2f2c1d7215d972f17078b20501e9c1033 Mon Sep 17 00:00:00 2001 From: "Viral B. Shah" Date: Thu, 3 Mar 2022 14:15:12 -0500 Subject: [PATCH 10/10] Update NNlib.jl --- src/NNlib.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NNlib.jl b/src/NNlib.jl index 47de37d32..c2dfc6925 100644 --- a/src/NNlib.jl +++ b/src/NNlib.jl @@ -12,7 +12,7 @@ using LinearAlgebra using LinearAlgebra: BlasFloat, Transpose, Adjoint, AdjOrTransAbsMat using LinearAlgebra.BLAS: BlasInt, @blasfunc -const libblas = "libblastrampoline" +const libblas = Base.libblas_name const IntOrIntTuple = Union{Integer, NTuple{N,<:Integer} where N} const Numeric = Union{AbstractArray{<:T}, T} where {T<:Number}