Open
Conversation
Contributor
|
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/NDTensors/ext/NDTensorscuTENSORExt/contract.jl b/NDTensors/ext/NDTensorscuTENSORExt/contract.jl
index 64ffa26b..7ed580ed 100644
--- a/NDTensors/ext/NDTensorscuTENSORExt/contract.jl
+++ b/NDTensors/ext/NDTensorscuTENSORExt/contract.jl
@@ -1,7 +1,6 @@
using Base: ReshapedArray
using NDTensors.Expose: Exposed, expose, unexpose
-using NDTensors: NDTensors, BlockSparseTensor, DenseTensor, array,
-blockdims, data, eachnzblock, inds, nblocks, nzblocks
+using NDTensors: NDTensors, BlockSparseTensor, DenseTensor, array, blockdims, data, eachnzblock, inds, nblocks, nzblocks
using cuTENSOR: cuTENSOR, CuArray, CuTensor
# Handle cases that can't be handled by `cuTENSOR.jl`
@@ -32,10 +31,11 @@ function ITensor_to_cuTensorBS(T::BlockSparseTensor)
nzblock_coords_t1 = [Int64.(x.data) for x in nzblocks(T)]
block_per_mode_t1 = length.(block_extents_t1)
is = [i for i in 1:ndims(T)]
- return cuTENSOR.CuTensorBS(blocks_t1, block_per_mode_t1, block_extents_t1, nzblock_coords_t1, is);
+ return cuTENSOR.CuTensorBS(blocks_t1, block_per_mode_t1, block_extents_t1, nzblock_coords_t1, is)
end
-function NDTensors._contract!(R::Exposed{<:CuArray, <:BlockSparseTensor},
+function NDTensors._contract!(
+ R::Exposed{<:CuArray, <:BlockSparseTensor},
labelsR,
tensor1::Exposed{<:CuArray, <:BlockSparseTensor},
labelstensor1,
@@ -44,9 +44,9 @@ function NDTensors._contract!(R::Exposed{<:CuArray, <:BlockSparseTensor},
grouped_contraction_plan,
executor,
)
- N1 = ndims(unexpose(tensor1))
- N2 = ndims(unexpose(tensor2))
- NR = ndims(unexpose(R))
+ N1 = ndims(unexpose(tensor1))
+ N2 = ndims(unexpose(tensor2))
+ NR = ndims(unexpose(R))
if NDTensors.using_CuTensorBS() && (N1 > 0) && (N2 > 0) && (NR > 0)
# println("Using new function")
cuR = ITensor_to_cuTensorBS(unexpose(R))
@@ -61,14 +61,14 @@ function NDTensors._contract!(R::Exposed{<:CuArray, <:BlockSparseTensor},
return R
else
return NDTensors._contract!(
- unexpose(R),
- labelsR,
- unexpose(tensor1),
- labelstensor1,
- unexpose(tensor2),
- labelstensor2,
- grouped_contraction_plan,
- executor,
+ unexpose(R),
+ labelsR,
+ unexpose(tensor1),
+ labelstensor1,
+ unexpose(tensor2),
+ labelstensor2,
+ grouped_contraction_plan,
+ executor,
)
end
end
diff --git a/NDTensors/src/NDTensors.jl b/NDTensors/src/NDTensors.jl
index e7a60688..919ec437 100644
--- a/NDTensors/src/NDTensors.jl
+++ b/NDTensors/src/NDTensors.jl
@@ -241,7 +241,6 @@ end
function backend_octavian end
-
_using_CuTensorBS = false
using_CuTensorBS() = _using_CuTensorBS
diff --git a/NDTensors/src/blocksparse/contract_generic.jl b/NDTensors/src/blocksparse/contract_generic.jl
index 39b67fac..97afe393 100644
--- a/NDTensors/src/blocksparse/contract_generic.jl
+++ b/NDTensors/src/blocksparse/contract_generic.jl
@@ -71,19 +71,21 @@ function contract!(
)
return R
end
-function _contract!(R::Exposed,
+function _contract!(
+ R::Exposed,
labelsR,
tensor1::Exposed,
labelstensor1,
tensor2::Exposed,
labelstensor2,
grouped_contraction_plan,
- executor,
+ executor
)
- _contract!(unexpose(R), labelsR,
- unexpose(tensor1), labelstensor1,
- unexpose(tensor2), labelstensor2,
- grouped_contraction_plan,executor
+ return _contract!(
+ unexpose(R), labelsR,
+ unexpose(tensor1), labelstensor1,
+ unexpose(tensor2), labelstensor2,
+ grouped_contraction_plan, executor
)
end
# Function barrier to improve type stability, |
Member
|
Great to see this, thanks @kmp5VT. I guess this relies on JuliaGPU/CUDA.jl#3057? Once that is merged, would we just need to install the latest version of cuTENSOR/cuTENSOR.jl and the new backend in this PR "just works"? |
Collaborator
|
Looks nice and very minimal. Thanks Karl! |
Collaborator
Author
|
@mtfishman In NDTensors I also added a internal variable |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please include a summary of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes #(issue)
If practical and applicable, please include a minimal demonstration of the previous behavior and new behavior below.
Minimal demonstration of previous behavior
Minimal demonstration of new behavior
How Has This Been Tested?
Please add tests that verify your changes to a file in the
testdirectory.Please give a summary of the tests that you added to verify your changes.
Checklist:
~/.julia/dev/ITensors) to format your code according to our style guidelines.