Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
exatn
Commits
c190582a
Commit
c190582a
authored
Dec 10, 2021
by
Dmitry I. Lyakh
Browse files
Fixed inconsistency in initTensorsRnd to make sure unmutable tensors are not initialized.
Signed-off-by:
Dmitry I. Lyakh
<
quant4me@gmail.com
>
parent
ce6c2ce8
Pipeline
#184751
failed with stage
in 5 minutes and 59 seconds
Changes
1
Pipelines
34
Hide whitespace changes
Inline
Side-by-side
src/exatn/num_server.cpp
View file @
c190582a
/** ExaTN::Numerics: Numerical server
REVISION: 2021/1
0/3
0
REVISION: 2021/1
2/1
0
Copyright (C) 2018-2021 Dmitry I. Lyakh (Liakh)
Copyright (C) 2018-2021 Oak Ridge National Laboratory (UT-Battelle) **/
...
...
@@ -1565,14 +1565,12 @@ bool NumServer::initTensorRndSync(const std::string & name)
bool
NumServer
::
initTensorsRnd
(
TensorNetwork
&
tensor_network
)
{
bool
success
=
true
;
std
::
unordered_set
<
std
::
string
>
tensor_names
;
for
(
auto
tens
=
tensor_network
.
cbegin
();
tens
!=
tensor_network
.
cend
();
++
tens
){
auto
tensor
=
tens
->
second
.
getTensor
();
const
auto
&
tens_name
=
tensor
->
getName
();
if
(
tens
->
first
!=
0
){
//input tensor
if
(
tensorAllocated
(
tens_name
)){
//auto res = tensor_names.emplace(tens_name);
success
=
initTensorRnd
(
tens_name
);
if
(
tens
->
second
.
isOptimizable
())
success
=
initTensorRnd
(
tens_name
);
}
else
{
success
=
false
;
}
...
...
@@ -1581,25 +1579,18 @@ bool NumServer::initTensorsRnd(TensorNetwork & tensor_network)
}
if
(
!
success
)
break
;
}
if
(
success
){
for
(
const
auto
&
tens_name
:
tensor_names
){
success
=
initTensorRnd
(
tens_name
);
if
(
!
success
)
break
;
}
}
return
success
;
}
bool
NumServer
::
initTensorsRndSync
(
TensorNetwork
&
tensor_network
)
{
bool
success
=
true
;
std
::
unordered_set
<
std
::
string
>
tensor_names
;
for
(
auto
tens
=
tensor_network
.
cbegin
();
tens
!=
tensor_network
.
cend
();
++
tens
){
auto
tensor
=
tens
->
second
.
getTensor
();
const
auto
&
tens_name
=
tensor
->
getName
();
if
(
tens
->
first
!=
0
){
//input tensor
if
(
tensorAllocated
(
tens_name
)){
//auto res = tensor_names.emplace(tens_name);
success
=
initTensorRndSync
(
tens_name
);
if
(
tens
->
second
.
isOptimizable
())
success
=
initTensorRndSync
(
tens_name
);
}
else
{
success
=
false
;
}
...
...
@@ -1608,26 +1599,19 @@ bool NumServer::initTensorsRndSync(TensorNetwork & tensor_network)
}
if
(
!
success
)
break
;
}
if
(
success
){
for
(
const
auto
&
tens_name
:
tensor_names
){
success
=
initTensorRndSync
(
tens_name
);
if
(
!
success
)
break
;
}
}
return
success
;
}
bool
NumServer
::
initTensorsRnd
(
TensorExpansion
&
tensor_expansion
)
{
bool
success
=
true
;
std
::
unordered_set
<
std
::
string
>
tensor_names
;
for
(
auto
tensor_network
=
tensor_expansion
.
cbegin
();
tensor_network
!=
tensor_expansion
.
cend
();
++
tensor_network
){
for
(
auto
tens
=
tensor_network
->
network
->
cbegin
();
tens
!=
tensor_network
->
network
->
cend
();
++
tens
){
auto
tensor
=
tens
->
second
.
getTensor
();
const
auto
&
tens_name
=
tensor
->
getName
();
if
(
tens
->
first
!=
0
){
//input tensor
if
(
tensorAllocated
(
tens_name
)){
//auto res = tensor_names.emplace(tens_name);
success
=
initTensorRnd
(
tens_name
);
if
(
tens
->
second
.
isOptimizable
())
success
=
initTensorRnd
(
tens_name
);
}
else
{
success
=
false
;
}
...
...
@@ -1637,26 +1621,19 @@ bool NumServer::initTensorsRnd(TensorExpansion & tensor_expansion)
if
(
!
success
)
break
;
}
}
if
(
success
){
for
(
const
auto
&
tens_name
:
tensor_names
){
success
=
initTensorRnd
(
tens_name
);
if
(
!
success
)
break
;
}
}
return
success
;
}
bool
NumServer
::
initTensorsRndSync
(
TensorExpansion
&
tensor_expansion
)
{
bool
success
=
true
;
std
::
unordered_set
<
std
::
string
>
tensor_names
;
for
(
auto
tensor_network
=
tensor_expansion
.
cbegin
();
tensor_network
!=
tensor_expansion
.
cend
();
++
tensor_network
){
for
(
auto
tens
=
tensor_network
->
network
->
cbegin
();
tens
!=
tensor_network
->
network
->
cend
();
++
tens
){
auto
tensor
=
tens
->
second
.
getTensor
();
const
auto
&
tens_name
=
tensor
->
getName
();
if
(
tens
->
first
!=
0
){
//input tensor
if
(
tensorAllocated
(
tens_name
)){
//auto res = tensor_names.emplace(tens_name);
success
=
initTensorRndSync
(
tens_name
);
if
(
tens
->
second
.
isOptimizable
())
success
=
initTensorRndSync
(
tens_name
);
}
else
{
success
=
false
;
}
...
...
@@ -1666,11 +1643,6 @@ bool NumServer::initTensorsRndSync(TensorExpansion & tensor_expansion)
if
(
!
success
)
break
;
}
}
if
(
success
){
for
(
const
auto
&
tens_name
:
tensor_names
){
success
=
initTensorRndSync
(
tens_name
);
if
(
!
success
)
break
;
}
}
return
success
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment