Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aidge_core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cyril Moineau
aidge_core
Commits
cb4952a7
Commit
cb4952a7
authored
1 year ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
Added much strong test for GraphView::clone with deleted nodes
parent
04410d9a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/aidge/graph/Testing.hpp
+2
-0
2 additions, 0 deletions
include/aidge/graph/Testing.hpp
src/graph/Testing.cpp
+20
-5
20 additions, 5 deletions
src/graph/Testing.cpp
unit_tests/graph/Test_GraphView.cpp
+15
-12
15 additions, 12 deletions
unit_tests/graph/Test_GraphView.cpp
with
37 additions
and
17 deletions
include/aidge/graph/Testing.hpp
+
2
−
0
View file @
cb4952a7
...
...
@@ -40,6 +40,8 @@ struct RandomDAG {
std
::
vector
<
std
::
string
>
types
=
{
"Fictive"
};
/// @brief Weights of each node type, used to compute the probability of generating this type
std
::
vector
<
float
>
typesWeights
=
{
1.0
};
/// @brief Type of node that should be omitted from the generated topology
std
::
string
omitType
;
/**
* Generate a DAG according to the parameters of the class.
...
...
This diff is collapsed.
Click to expand it.
src/graph/Testing.cpp
+
20
−
5
View file @
cb4952a7
...
...
@@ -20,9 +20,11 @@ std::pair<Aidge::NodePtr, std::set<Aidge::NodePtr>> Aidge::RandomDAG::gen(std::m
std
::
discrete_distribution
<>
dType
(
typesWeights
.
begin
(),
typesWeights
.
end
());
std
::
vector
<
std
::
pair
<
int
,
int
>>
nbIOs
;
std
::
vector
<
std
::
string
>
nodesType
;
for
(
size_t
i
=
0
;
i
<
nbNodes
;
++
i
)
{
const
auto
nbIn
=
1
+
dIn
(
gen
);
nbIOs
.
push_back
(
std
::
make_pair
(
nbIn
,
1
+
dOut
(
gen
)));
nodesType
.
push_back
(
types
[
dType
(
gen
)]);
}
std
::
vector
<
int
>
nodesSeq
(
nbNodes
);
...
...
@@ -32,9 +34,8 @@ std::pair<Aidge::NodePtr, std::set<Aidge::NodePtr>> Aidge::RandomDAG::gen(std::m
std
::
vector
<
NodePtr
>
nodes
(
nbNodes
,
nullptr
);
for
(
auto
idx
:
nodesSeq
)
{
const
std
::
string
type
=
types
[
dType
(
gen
)];
const
std
::
string
name
=
type
+
std
::
to_string
(
idx
);
nodes
[
idx
]
=
GenericOperator
(
type
.
c_str
(),
nbIOs
[
idx
].
first
,
nbIOs
[
idx
].
first
,
nbIOs
[
idx
].
second
,
name
.
c_str
());
const
std
::
string
name
=
nodesType
[
idx
]
+
std
::
to_string
(
idx
);
nodes
[
idx
]
=
GenericOperator
(
nodesType
[
idx
].
c_str
(),
nbIOs
[
idx
].
first
,
nbIOs
[
idx
].
first
,
nbIOs
[
idx
].
second
,
name
.
c_str
());
}
for
(
size_t
i
=
0
;
i
<
nbNodes
;
++
i
)
{
...
...
@@ -42,14 +43,28 @@ std::pair<Aidge::NodePtr, std::set<Aidge::NodePtr>> Aidge::RandomDAG::gen(std::m
for
(
size_t
outId
=
0
;
outId
<
nodes
[
i
]
->
nbOutputs
();
++
outId
)
{
for
(
size_t
inId
=
0
;
inId
<
nodes
[
j
]
->
nbInputs
();
++
inId
)
{
if
(
dLink
(
gen
))
{
nodes
[
i
]
->
addChild
(
nodes
[
j
],
outId
,
inId
);
if
(
nodes
[
i
]
->
type
()
!=
omitType
&&
nodes
[
j
]
->
type
()
!=
omitType
)
{
nodes
[
i
]
->
addChild
(
nodes
[
j
],
outId
,
inId
);
}
break
;
}
}
}
}
}
return
std
::
make_pair
(
nodes
[
0
],
std
::
set
<
NodePtr
>
(
nodes
.
begin
(),
nodes
.
end
()));
NodePtr
rootNode
=
nullptr
;
std
::
set
<
NodePtr
>
nodesSet
;
for
(
size_t
i
=
0
;
i
<
nbNodes
;
++
i
)
{
if
(
nodes
[
i
]
->
type
()
!=
omitType
)
{
if
(
rootNode
==
nullptr
)
{
rootNode
=
nodes
[
i
];
}
nodesSet
.
insert
(
nodes
[
i
]);
}
}
return
std
::
make_pair
(
rootNode
,
nodesSet
);
}
std
::
string
Aidge
::
nodePtrToType
(
NodePtr
node
)
{
...
...
This diff is collapsed.
Click to expand it.
unit_tests/graph/Test_GraphView.cpp
+
15
−
12
View file @
cb4952a7
...
...
@@ -95,24 +95,27 @@ TEST_CASE("clone_with_delete") {
randDAG
.
types
=
{
"Fictive"
,
"DelFictive"
};
randDAG
.
typesWeights
=
{
0.9
,
0.1
};
const
auto
g1
=
std
::
make_shared
<
GraphView
>
(
"g1"
);
g1
->
add
(
randDAG
.
gen
(
seed
,
10
));
const
bool
unicity1
=
g1
->
add
(
randDAG
.
gen
(
seed
,
10
));
g1
->
save
(
"./clone_with_delete1"
);
if
(
unicity1
)
{
randDAG
.
omitType
=
"DelFictive"
;
const
auto
g2
=
std
::
make_shared
<
GraphView
>
(
"g2"
);
const
bool
unicity2
=
g2
->
add
(
randDAG
.
gen
(
seed
,
10
));
try
{
const
auto
g2
=
g1
->
cloneCallback
(
&
nodeDel
);
g1
->
save
(
"./clone_with_delete1"
);
g2
->
save
(
"./clone_with_delete2"
);
if
(
g2
->
getNodes
().
size
()
<
g1
->
getNodes
().
size
())
{
g2
->
save
(
"./clone_with_delete2"
);
try
{
const
auto
gCloned
=
g1
->
cloneCallback
(
&
nodeDel
);
// These tests are not necessarily true if the deleted node is an input/output node!
//
REQUIRE(
g1
->getOrderedInputs()
.size() ==
g2->getOrderedInputs()
.size(
));
//
REQUIRE(
g1
->getOrderedOutputs()
.size() ==
g2->getOrderedOutputs()
.size(
));
REQUIRE
(
nodePtrTo
(
gCloned
->
getNodes
(),
nodePtrToName
)
==
nodePtrTo
(
g2
->
getNodes
(),
nodePtrToName
));
REQUIRE
(
nodePtrTo
(
gCloned
->
getOrderedInputs
()
,
nodePtrToName
)
==
nodePtrTo
(
g2
->
getOrderedInputs
()
,
nodePtrToName
));
REQUIRE
(
nodePtrTo
(
gCloned
->
getOrderedOutputs
()
,
nodePtrToName
)
==
nodePtrTo
(
g2
->
getOrderedOutputs
()
,
nodePtrToName
));
++
nbClonedWithDelete
;
}
}
catch
(
const
std
::
runtime_error
&
error
)
{
// pass
catch
(
const
std
::
runtime_error
&
error
)
{
// pass
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment