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
4 changes: 1 addition & 3 deletions NDTensors/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NDTensors"
uuid = "23ae76d9-e61a-49c4-8f12-3f1a16adf9cf"
authors = ["Matthew Fishman <[email protected]>"]
version = "0.4.13"
version = "0.4.14"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand All @@ -28,7 +28,6 @@ Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
StridedViews = "4db3bf67-4bd7-4b4e-b153-31dc3fb37143"
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"

[weakdeps]
Expand Down Expand Up @@ -88,7 +87,6 @@ StridedViews = "0.2.2, 0.3, 0.4"
TBLIS = "0.2"
TimerOutputs = "0.5.5"
TupleTools = "1.2.0"
TypeParameterAccessors = "0.3"
VectorInterface = "0.4.2, 0.5"
cuTENSOR = "2"
julia = "1.10"
Expand Down
9 changes: 9 additions & 0 deletions NDTensors/ext/NDTensorsAMDGPUExt/NDTensorsAMDGPUExt.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
module NDTensorsAMDGPUExt

module Vendored
include(
joinpath(
"..", "..", "src", "vendored", "TypeParameterAccessors", "ext",
"TypeParameterAccessorsAMDGPUExt.jl"
)
)
end

include("append.jl")
include("copyto.jl")
include("set_types.jl")
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsAMDGPUExt/adapt.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NDTensors: NDTensors, EmptyStorage, adapt_storagetype, emptytype
using NDTensors.AMDGPUExtensions: AMDGPUExtensions, ROCArrayAdaptor
using NDTensors.GPUArraysCoreExtensions: storagemode
using NDTensors.TypeParameterAccessors:
using NDTensors.Vendored.TypeParameterAccessors:
default_type_parameters, set_type_parameters, type_parameters
using Adapt: Adapt, adapt
using AMDGPU: AMDGPU, ROCArray, ROCVector
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsAMDGPUExt/linearalgebra.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using NDTensors.AMDGPUExtensions: roc
using NDTensors.Expose: Expose, Exposed, expose, ql, ql_positive
using NDTensors.GPUArraysCoreExtensions: cpu
using NDTensors.TypeParameterAccessors: unwrap_array_type
using NDTensors.Vendored.TypeParameterAccessors: unwrap_array_type
using LinearAlgebra: svd
using Adapt: adapt
using AMDGPU: ROCMatrix
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsAMDGPUExt/set_types.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AMDGPU: ROCArray
using NDTensors.GPUArraysCoreExtensions: storagemode
using NDTensors.TypeParameterAccessors: TypeParameterAccessors, Position
using NDTensors.Vendored.TypeParameterAccessors: TypeParameterAccessors, Position

TypeParameterAccessors.position(::Type{<:ROCArray}, ::typeof(storagemode)) = Position(3)
11 changes: 11 additions & 0 deletions NDTensors/ext/NDTensorsCUDAExt/NDTensorsCUDAExt.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
module NDTensorsCUDAExt

module Vendored
include(
joinpath(
"..", "..", "src", "vendored", "TypeParameterAccessors", "ext",
"TypeParameterAccessorsCUDAExt.jl"
)
)
end

include("append.jl")
include("default_kwargs.jl")
include("copyto.jl")
Expand All @@ -9,4 +19,5 @@ include("indexing.jl")
include("linearalgebra.jl")
include("mul.jl")
include("permutedims.jl")

end
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsCUDAExt/adapt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Functors: fmap
using NDTensors: NDTensors, EmptyStorage, adapt_storagetype, emptytype
using NDTensors.CUDAExtensions: CUDAExtensions, CuArrayAdaptor
using NDTensors.GPUArraysCoreExtensions: storagemode
using NDTensors.TypeParameterAccessors:
using NDTensors.Vendored.TypeParameterAccessors:
default_type_parameters, set_type_parameters, type_parameters

function CUDAExtensions.cu(xs; storagemode = default_type_parameters(CuArray, storagemode))
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsCUDAExt/linearalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using LinearAlgebra: Adjoint, svd
using NDTensors: NDTensors
using NDTensors.Expose: Expose, expose, ql, ql_positive
using NDTensors.GPUArraysCoreExtensions: cpu
using NDTensors.TypeParameterAccessors: unwrap_array_type
using NDTensors.Vendored.TypeParameterAccessors: unwrap_array_type
function NDTensors.svd_catch_error(A::CuMatrix; alg::String = "jacobi_algorithm")
if alg == "jacobi_algorithm"
alg = CUDA.CUSOLVER.JacobiAlgorithm()
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsCUDAExt/set_types.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using CUDA: CuArray
using NDTensors.GPUArraysCoreExtensions: storagemode
using NDTensors.TypeParameterAccessors: TypeParameterAccessors, Position
using NDTensors.Vendored.TypeParameterAccessors: TypeParameterAccessors, Position

function TypeParameterAccessors.position(::Type{<:CuArray}, ::typeof(storagemode))
return Position(3)
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsGPUArraysCoreExt/contract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Adapt: adapt
using GPUArraysCore: AbstractGPUArray
using NDTensors: NDTensors, DenseTensor, DiagTensor, contract!, dense, inds, Tensor
using NDTensors.Expose: Exposed, expose, unexpose
using NDTensors.TypeParameterAccessors: parenttype, set_ndims
using NDTensors.Vendored.TypeParameterAccessors: parenttype, set_ndims

function NDTensors.contract!(
output_tensor::Exposed{<:AbstractGPUArray, <:DenseTensor},
Expand Down
11 changes: 11 additions & 0 deletions NDTensors/ext/NDTensorsJLArraysExt/NDTensorsJLArraysExt.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
module NDTensorsJLArraysExt

module Vendored
include(
joinpath(
"..", "..", "src", "vendored", "TypeParameterAccessors", "ext",
"TypeParameterAccessorsJLArraysExt.jl"
)
)
end

include("copyto.jl")
include("indexing.jl")
include("linearalgebra.jl")
include("mul.jl")
include("permutedims.jl")

end
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsJLArraysExt/linearalgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using LinearAlgebra: LinearAlgebra, Hermitian, Symmetric, qr, eigen
using NDTensors: NDTensors
using NDTensors.Expose: Expose, expose, qr, qr_positive, ql, ql_positive
using NDTensors.GPUArraysCoreExtensions: cpu
using NDTensors.TypeParameterAccessors: unwrap_array_type
using NDTensors.Vendored.TypeParameterAccessors: unwrap_array_type

## TODO this function exists because of the same issue below. when
## that issue is resolved we can rely on the abstractarray version of
Expand Down
9 changes: 9 additions & 0 deletions NDTensors/ext/NDTensorsMetalExt/NDTensorsMetalExt.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
module NDTensorsMetalExt

module Vendored
include(
joinpath(
"..", "..", "src", "vendored", "TypeParameterAccessors", "ext",
"TypeParameterAccessorsMetalExt.jl"
)
)
end

include("adapt.jl")
include("set_types.jl")
include("indexing.jl")
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsMetalExt/adapt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using NDTensors: NDTensors, EmptyStorage, adapt_storagetype, emptytype
using NDTensors.Expose: Exposed
using NDTensors.MetalExtensions: MetalExtensions, MtlArrayAdaptor
using NDTensors.GPUArraysCoreExtensions: GPUArraysCoreExtensions
using NDTensors.TypeParameterAccessors: set_type_parameters, type_parameters
using NDTensors.Vendored.TypeParameterAccessors: set_type_parameters, type_parameters

GPUArraysCoreExtensions.cpu(e::Exposed{<:MtlArray}) = adapt(Array, e)

Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsMetalExt/linearalgebra.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Metal: MtlMatrix
using LinearAlgebra: LinearAlgebra, qr, eigen, svd
using NDTensors.Expose: qr_positive, ql_positive, ql
using NDTensors.TypeParameterAccessors:
using NDTensors.Vendored.TypeParameterAccessors:
set_type_parameters, type_parameters, unwrap_array_type

function LinearAlgebra.qr(A::Exposed{<:MtlMatrix})
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/ext/NDTensorsMetalExt/set_types.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Metal: MtlArray
using NDTensors.GPUArraysCoreExtensions: storagemode
using NDTensors.TypeParameterAccessors: TypeParameterAccessors, Position
using NDTensors.Vendored.TypeParameterAccessors: TypeParameterAccessors, Position

function TypeParameterAccessors.position(::Type{<:MtlArray}, ::typeof(storagemode))
return Position(3)
Expand Down
21 changes: 21 additions & 0 deletions NDTensors/src/NDTensors.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
module NDTensors

module Vendored
include(
joinpath(
"vendored", "TypeParameterAccessors", "src", "TypeParameterAccessors.jl"
)
)
include(
joinpath(
"vendored", "TypeParameterAccessors", "ext",
"TypeParameterAccessorsFillArraysExt.jl"
)
)
include(
joinpath(
"vendored", "TypeParameterAccessors", "ext",
"TypeParameterAccessorsStridedViewsExt.jl"
)
)
end

#####################################
# Imports and exports
#
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/abstractarray/generic_array_constructors.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors:
using .Vendored.TypeParameterAccessors:
unwrap_array_type,
specify_default_type_parameters,
specify_type_parameters,
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/abstractarray/iscu.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: unwrap_array_type
using .Vendored.TypeParameterAccessors: unwrap_array_type
# TODO: Make `isgpu`, `ismtl`, etc.
# For `isgpu`, will require a `NDTensorsGPUArrayCoreExt`.
iscu(A::AbstractArray) = iscu(typeof(A))
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/abstractarray/set_types.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors
using .Vendored.TypeParameterAccessors: TypeParameterAccessors

"""
# Do we still want to define things like this?
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/abstractarray/similar.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Base: DimOrInd, Dims, OneTo
using TypeParameterAccessors: IsWrappedArray, unwrap_array_type, set_eltype, similartype
using .Vendored.TypeParameterAccessors: IsWrappedArray, unwrap_array_type, set_eltype, similartype

## Custom `NDTensors.similar` implementation.
## More extensive than `Base.similar`.
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/adapt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ double_precision(x) = fmap(x -> adapt(double_precision(eltype(x)), x), x)
# Used to adapt `EmptyStorage` types
#

using TypeParameterAccessors: specify_type_parameters
using .Vendored.TypeParameterAccessors: specify_type_parameters
function adapt_storagetype(to::Type{<:AbstractVector}, x::Type{<:TensorStorage})
return set_datatype(x, specify_type_parameters(to, eltype, eltype(x)))
end
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/blocksparse/blockdims.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors
using .Vendored.TypeParameterAccessors: TypeParameterAccessors

"""
BlockDim
Expand Down
6 changes: 3 additions & 3 deletions NDTensors/src/blocksparse/blocksparsetensor.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using SparseArrays: nnz
using TypeParameterAccessors: similartype
using .Vendored.TypeParameterAccessors: similartype

#
# BlockSparseTensor (Tensor using BlockSparse storage)
Expand Down Expand Up @@ -258,7 +258,7 @@ end
# Defaults to adding zeros.
# Returns the offset of the new block added.
# XXX rename to insertblock!, no need to return offset
using TypeParameterAccessors: unwrap_array_type
using .Vendored.TypeParameterAccessors: unwrap_array_type
using .Expose: Exposed, expose, unexpose
function insertblock_offset!(T::BlockSparseTensor{ElT, N}, newblock::Block{N}) where {ElT, N}
newdim = blockdim(T, newblock)
Expand Down Expand Up @@ -792,7 +792,7 @@ end
# <fermions>
permfactor(perm, block, inds) = 1

using TypeParameterAccessors: set_type_parameters, parenttype
using .Vendored.TypeParameterAccessors: set_type_parameters, parenttype
function permutedims!(
R::BlockSparseTensor{<:Number, N},
T::BlockSparseTensor{<:Number, N},
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/blocksparse/diagblocksparse.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using LinearAlgebra: LinearAlgebra
using TypeParameterAccessors: similartype
using .Vendored.TypeParameterAccessors: similartype

export DiagBlockSparse, DiagBlockSparseTensor

Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/blocksparse/linearalgebra.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: unwrap_array_type
using .Vendored.TypeParameterAccessors: unwrap_array_type
using .Expose: expose
const BlockSparseMatrix{ElT, StoreT, IndsT} = BlockSparseTensor{ElT, 2, StoreT, IndsT}
const DiagBlockSparseMatrix{ElT, StoreT, IndsT} = DiagBlockSparseTensor{ElT, 2, StoreT, IndsT}
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/blocksparse/similar.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using SparseArrays: nnz
using TypeParameterAccessors: similartype
using .Vendored.TypeParameterAccessors: similartype

# NDTensors.similar
function similar(storagetype::Type{<:BlockSparse}, blockoffsets::BlockOffsets, dims::Tuple)
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/default_kwargs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: unwrap_array_type
using .Vendored.TypeParameterAccessors: unwrap_array_type
replace_nothing(::Nothing, replacement) = replacement
replace_nothing(value, replacement) = value

Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/dense/dense.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ dense(storagetype::Type{<:Dense}) = storagetype
# TODO: make these more general, move to tensorstorage.jl
datatype(storetype::Type{<:Dense{<:Any, DataT}}) where {DataT} = DataT

using TypeParameterAccessors: unwrap_array_type
using .Vendored.TypeParameterAccessors: unwrap_array_type
function promote_rule(
::Type{<:Dense{ElT1, DataT1}}, ::Type{<:Dense{ElT2, DataT2}}
) where {ElT1, DataT1, ElT2, DataT2}
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/dense/generic_array_constructors.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors:
using .Vendored.TypeParameterAccessors:
default_type_parameters,
parenttype,
set_eltype,
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/dense/set_types.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors, Position, parenttype
using .Vendored.TypeParameterAccessors: TypeParameterAccessors, Position, parenttype

function set_datatype(storagetype::Type{<:Dense}, datatype::Type{<:AbstractVector})
return Dense{eltype(datatype), datatype}
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/diag/diagtensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function dense(::Type{<:Tensor{ElT, N, StoreT, IndsT}}) where {ElT, N, StoreT <:
return Tensor{ElT, N, dense(StoreT), IndsT}
end

using TypeParameterAccessors: unwrap_array_type
using .Vendored.TypeParameterAccessors: unwrap_array_type
# convert to Dense
function dense(T::DiagTensor)
R = zeros(dense(typeof(T)), inds(T))
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/diag/set_types.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors
using .Vendored.TypeParameterAccessors: TypeParameterAccessors

function TypeParameterAccessors.set_eltype(storagetype::Type{<:UniformDiag}, eltype::Type)
return Diag{eltype, eltype}
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/diag/similar.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors
using .Vendored.TypeParameterAccessors: TypeParameterAccessors

# NDTensors.similar
function similar(storagetype::Type{<:Diag}, dims::Dims)
Expand Down
2 changes: 1 addition & 1 deletion NDTensors/src/dims.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors
using .Vendored.TypeParameterAccessors: TypeParameterAccessors

export dense, dims, dim, mindim, diaglength

Expand Down
4 changes: 2 additions & 2 deletions NDTensors/src/empty/empty.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using SparseArrays: SparseArrays
using TypeParameterAccessors: TypeParameterAccessors, set_eltype, similartype
using .Vendored.TypeParameterAccessors: TypeParameterAccessors, set_eltype, similartype

#
# Represents a tensor order that could be set to any order.
Expand Down Expand Up @@ -95,6 +95,6 @@ function Base.show(io::IO, mime::MIME"text/plain", S::EmptyStorage)
return println(io, typeof(S))
end

using TypeParameterAccessors: TypeParameterAccessors
using .Vendored.TypeParameterAccessors: TypeParameterAccessors
TypeParameterAccessors.parenttype(empty::Type{<:EmptyStorage}) = storagetype(empty)
zero(empty::EmptyStorage) = empty
1 change: 1 addition & 0 deletions NDTensors/src/lib/AMDGPUExtensions/src/AMDGPUExtensions.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module AMDGPUExtensions

include("roc.jl")

end
2 changes: 1 addition & 1 deletion NDTensors/src/lib/AMDGPUExtensions/src/roc.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors, Position
using ..Vendored.TypeParameterAccessors: TypeParameterAccessors, Position
using ..GPUArraysCoreExtensions: storagemode
# Implemented in NDTensorsAMDGPUExt
function roc end
Expand Down
1 change: 1 addition & 0 deletions NDTensors/src/lib/CUDAExtensions/src/CUDAExtensions.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module CUDAExtensions

include("cuda.jl")

end
2 changes: 1 addition & 1 deletion NDTensors/src/lib/CUDAExtensions/src/cuda.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TypeParameterAccessors: TypeParameterAccessors, Position
using ..Vendored.TypeParameterAccessors: TypeParameterAccessors, Position
using ..GPUArraysCoreExtensions: storagemode
# Implemented in NDTensorsCUDAExt
function cu end
Expand Down
1 change: 1 addition & 0 deletions NDTensors/src/lib/Expose/src/Expose.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module Expose

using SimpleTraits
using LinearAlgebra
using Base: ReshapedArray
Expand Down
Loading
Loading