Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "TensorAlgebra"
uuid = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
version = "0.23.2"
version = "0.23.3"
authors = ["ITensor developers <support@itensor.org> and contributors"]

[workspace]
Expand All @@ -15,19 +15,22 @@ StridedViews = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143"
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"

[weakdeps]
GPUArraysCore = "46192b85-c4d5-4398-a991-12ede77f4527"
Mooncake = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
TensorKitSectors = "13a9c161-d5da-41f0-bcbd-e1a08ae0647f"
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"

[extensions]
TensorAlgebraGPUArraysCoreExt = "GPUArraysCore"
TensorAlgebraMooncakeExt = "Mooncake"
TensorAlgebraTensorKitExt = ["TensorKit", "TensorOperations", "VectorInterface"]
TensorAlgebraTensorKitSectorsExt = "TensorKitSectors"
TensorAlgebraTensorOperationsExt = "TensorOperations"

[compat]
GPUArraysCore = "0.2"
LinearAlgebra = "1.10"
MatrixAlgebraKit = "0.6"
Mooncake = "0.4.202, 0.5"
Expand Down
9 changes: 9 additions & 0 deletions ext/TensorAlgebraGPUArraysCoreExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module TensorAlgebraGPUArraysCoreExt

using GPUArraysCore: @allowscalar, AnyGPUArray
using TensorAlgebra: TensorAlgebra

# `a[]` on a GPU array is a scalar index, which GPU array packages disallow by default.
TensorAlgebra.scalar(a::AnyGPUArray{<:Any, 0}) = @allowscalar a[]

end
6 changes: 5 additions & 1 deletion test/test_scalar.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using JLArrays: JLArray
using TensorAlgebra: scalar
using Test: @test, @testset
using Test: @test, @test_throws, @testset

@testset "scalar" begin
@test scalar(fill(3.0)) === 3.0
a = Array{Float64, 0}(undef)
a[] = 5.0
@test scalar(a) === 5.0
@test scalar(fill(2 + 3im)) === 2 + 3im
@test scalar(JLArray(fill(3.0))) === 3.0
@test scalar(reshape(JLArray([4.0]), ())) === 4.0
@test_throws ErrorException scalar(JLArray([3.0]))
end
Loading