@@ -57,19 +57,19 @@ function contract(a::Tensor, b::Tensor; kwargs...)
57
57
end
58
58
59
59
function allocate_result (
60
- :: typeof (contract), a:: Tensor , b:: Tensor ; fillzero= false , dims= (∩ (inds (a), inds (b))), out= nothing
60
+ :: typeof (contract), a:: Tensor , b:: Tensor ; fillzero= false , dims= (∩ (vinds (a), vinds (b))), out= nothing
61
61
)
62
- ia = collect (inds (a))
63
- ib = collect (inds (b))
62
+ ia = collect (vinds (a))
63
+ ib = collect (vinds (b))
64
64
i = ∩ (dims, ia, ib)
65
65
66
66
ic = if isnothing (out)
67
- Tuple ( setdiff (ia ∪ ib, i isa Base. AbstractVecOrTuple ? i : (i,)) )
67
+ setdiff (ia ∪ ib, i isa Base. AbstractVecOrTuple ? i : [i] )
68
68
else
69
69
out
70
70
end
71
71
72
- data = OMEinsum. get_output_array ((parent (a), parent (b)), [size (i in ia ? a : b, i) for i in ic]; fillzero)
72
+ data = OMEinsum. get_output_array ((parent (a), parent (b)), Int [size (i in ia ? a : b, i) for i in ic]; fillzero)
73
73
return Tensor (data, ic)
74
74
end
75
75
@@ -88,12 +88,12 @@ function contract(a::Tensor; kwargs...)
88
88
return contract! (c, a)
89
89
end
90
90
91
- function allocate_result (:: typeof (contract), a:: Tensor ; fillzero= false , dims= nonunique (inds (a)), out= nothing )
92
- ia = inds (a)
91
+ function allocate_result (:: typeof (contract), a:: Tensor ; fillzero= false , dims= nonunique (vinds (a)), out= nothing )
92
+ ia = vinds (a)
93
93
i = ∩ (dims, ia)
94
94
95
95
ic:: Vector{Symbol} = if isnothing (out)
96
- setdiff (ia, i isa Base. AbstractVecOrTuple ? i : (i,) )
96
+ setdiff (ia, i isa Base. AbstractVecOrTuple ? i : [i] )
97
97
else
98
98
out
99
99
end
@@ -114,11 +114,11 @@ contract(tensors::Tensor...; kwargs...) = reduce((x, y) -> contract(x, y; kwargs
114
114
Perform a binary tensor contraction operation between `a` and `b` and store the result in `c`.
115
115
"""
116
116
function contract! (c:: Tensor , a:: Tensor , b:: Tensor )
117
- ixs = (inds (a), inds (b))
118
- iy = inds (c)
117
+ ixs = (vinds (a), vinds (b))
118
+ iy = vinds (c)
119
119
xs = (parent (a), parent (b))
120
120
y = parent (c)
121
- size_dict = merge! (Dict {Symbol,Int} .([inds (a) .=> size (a), inds (b) .=> size (b)])... )
121
+ size_dict = merge! (Dict {Symbol,Int} .([vinds (a) .=> size (a), vinds (b) .=> size (b)])... )
122
122
123
123
einsum! (ixs, iy, xs, y, true , false , size_dict)
124
124
return c
130
130
Perform a unary tensor contraction operation on `a` and store the result in `c`.
131
131
"""
132
132
function contract! (y:: Tensor , x:: Tensor )
133
- ixs = (inds (x),)
134
- iy = inds (y)
135
- size_dict = Dict {Symbol,Int} (inds (x) .=> size (x))
133
+ ixs = (vinds (x),)
134
+ iy = vinds (y)
135
+ size_dict = Dict {Symbol,Int} (vinds (x) .=> size (x))
136
136
137
137
einsum! (ixs, iy, (parent (x),), parent (y), true , false , size_dict)
138
138
return y
0 commit comments