-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into BlockSparseArrays_fix_some_slicing
- Loading branch information
Showing
11 changed files
with
117 additions
and
44 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
NDTensors/ext/NDTensorsGPUArraysCoreExt/NDTensorsGPUArraysCoreExt.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module NDTensorsGPUArraysCoreExt | ||
include("contract.jl") | ||
include("blocksparsetensor.jl") | ||
end |
26 changes: 26 additions & 0 deletions
26
NDTensors/ext/NDTensorsGPUArraysCoreExt/blocksparsetensor.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using GPUArraysCore: @allowscalar, AbstractGPUArray | ||
using NDTensors: NDTensors, BlockSparseTensor, dense, diag, map_diag! | ||
using NDTensors.DiagonalArrays: diaglength | ||
using NDTensors.Expose: Exposed, unexpose | ||
|
||
## TODO to circumvent issues with blocksparse and scalar indexing | ||
## convert blocksparse GPU tensors to dense tensors and call diag | ||
## copying will probably have some impact on timing but this code | ||
## currently isn't used in the main code, just in tests. | ||
function NDTensors.diag(ETensor::Exposed{<:AbstractGPUArray,<:BlockSparseTensor}) | ||
return diag(dense(unexpose(ETensor))) | ||
end | ||
|
||
## TODO scalar indexing is slow here | ||
function NDTensors.map_diag!( | ||
f::Function, | ||
exposed_t_destination::Exposed{<:AbstractGPUArray,<:BlockSparseTensor}, | ||
exposed_t_source::Exposed{<:AbstractGPUArray,<:BlockSparseTensor}, | ||
) | ||
t_destination = unexpose(exposed_t_destination) | ||
t_source = unexpose(exposed_t_source) | ||
@allowscalar for i in 1:diaglength(t_destination) | ||
NDTensors.setdiagindex!(t_destination, f(NDTensors.getdiagindex(t_source, i)), i) | ||
end | ||
return t_destination | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters