Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
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
Houssem ROUIS
aidge_core
Commits
37a75592
Commit
37a75592
authored
6 months ago
by
Sylvain Bataillé
Browse files
Options
Downloads
Patches
Plain Diff
create AIDGE_TEST_0108000 for graphview::replace
parent
41e3501d
No related branches found
No related tags found
No related merge requests found
Pipeline
#60925
failed
6 months ago
Stage: static_analysis
Stage: build
Stage: test
Stage: coverage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unit_tests/graph/Test_GraphView.cpp
+148
-0
148 additions, 0 deletions
unit_tests/graph/Test_GraphView.cpp
with
148 additions
and
0 deletions
unit_tests/graph/Test_GraphView.cpp
+
148
−
0
View file @
37a75592
...
...
@@ -15,6 +15,7 @@
#include
<memory>
#include
<set>
#include
<string>
#include
<fstream>
#include
<catch2/catch_test_macros.hpp>
#include
<catch2/generators/catch_generators_random.hpp>
...
...
@@ -31,6 +32,32 @@
#include
"aidge/graph/OpArgs.hpp"
#include
"aidge/operator/GenericOperator.hpp"
#include
"aidge/operator/Producer.hpp"
#include
"aidge/utils/Log.hpp"
bool
removeFile
(
std
::
string
i_strFileName
)
{
return
remove
(
i_strFileName
.
c_str
());
}
bool
LoadTextFile
(
std
::
string
i_strFileName
,
std
::
vector
<
std
::
string
>
&
output
)
{
std
::
ifstream
file
(
i_strFileName
.
c_str
());
if
(
file
)
{
std
::
string
line
;
while
(
std
::
getline
(
file
,
line
)
)
{
output
.
push_back
(
line
);
}
}
else
{
return
false
;
}
return
true
;;
}
using
namespace
Aidge
;
...
...
@@ -816,6 +843,127 @@ TEST_CASE("[core/graph] GraphView(replace)", "[GraphView][replace]") {
}
}
/////////////////////////////////////////
// AIDGE_TEST_0108000
/////////////////////////////////////////
// Requirements tested:
// AIDGE_CORE_REQ_0108000
// AIDGE_CORE_REQ_0108090
//////////////////////////////////////////
// Initial conditions for each case:
// -log file initialized with 0 log
//////////////////////////////////////////
// test case 1: one input, one output
// 1/ graphview= other_input --> other1 --> old1 --> old2 --> other2
// 2/ replace ooldGraph= old1 --> old2 by newGraph = new1 --> new2
// 3/ verify :
// - output value of replace == TRUE
// - graphview = other_input --> other1 --> new1 --> new2 --> other2
// - old1 -and old2 are remove from graphview
//////////////////////////////////////////
// test case 2 multiple input, multiple output
// 1/ graphview= other_input1 --> other11 --> old11 --> old12 --> other21
// other_input2 --> other12 --> old121 --> old22 --> other22
// 2/ replace oldGraph= old11 --> old12 by newGraph= new11 --> new12
// old12 --> old22 new21 --> new22
// 3/ verify :
// - output value of replace == TRUE
// - graphview = other_input1 --> other11 --> new11 --> new12 --> other21
// other_input2 --> other12 --> new21 --> new22 --> other22
// - old1, old2, old21 and old22 are remove from graphview
//////////////////////////////////////////
// test case 3 none input, none output ?
//
TEST_CASE
(
"[core/graph] AIDGE_TEST_0108000: Replacing a set of nodes, same inputs and output"
,
"[GraphView][replace]"
)
{
SECTION
(
"test case 1 one input, one output"
)
{
removeFile
(
"my_log.txt"
);
Log
::
setFileName
(
"my_log.txt"
);
Log
::
setFileLevel
(
Log
::
Level
::
Warn
);
std
::
vector
<
std
::
string
>
logs
;
std
::
shared_ptr
<
GraphView
>
graphTest
=
std
::
make_shared
<
GraphView
>
(
"test_graph"
);
auto
otherInput
=
GenericOperator
(
"Producer"
,
{},
1
,
"other_input"
);
auto
other1
=
GenericOperator
(
"Other"
,
{
InputCategory
::
Data
},
1
,
"other1"
);
auto
myOld1
=
GenericOperator
(
"Old"
,
{
InputCategory
::
Data
},
1
,
"old1"
);
auto
myOld2
=
GenericOperator
(
"Old"
,
{
InputCategory
::
Data
},
1
,
"old2"
);
auto
other2
=
GenericOperator
(
"Other"
,
{
InputCategory
::
Data
},
1
,
"other2"
);
otherInput
->
addChild
(
other1
);
other1
->
addChild
(
myOld1
);
myOld1
->
addChild
(
myOld2
);
myOld2
->
addChild
(
other2
);
graphTest
->
add
({
other1
,
myOld1
,
myOld2
,
other2
});
auto
myNew1
=
GenericOperator
(
"New"
,
{
InputCategory
::
Data
},
1
,
"new1"
);
auto
myNew2
=
GenericOperator
(
"New"
,
{
InputCategory
::
Data
},
1
,
"new2"
);
myNew1
->
addChild
(
myNew2
);
bool
retValue
=
GraphView
::
replace
({
myOld1
,
myOld2
},
{
myNew1
,
myNew2
});
CHECK
(
LoadTextFile
(
"my_log.txt"
,
logs
));
CHECK
(
logs
.
size
()
==
0
);
CHECK
(
graphTest
->
getNodes
()
==
std
::
set
<
std
::
shared_ptr
<
Node
>>
({
other1
,
myNew1
,
myNew2
,
other2
}));
graphTest
->
save
(
"myGraph"
,
true
,
true
);
CHECK
(
retValue
);
CHECK
(
myNew1
->
input
(
0
).
first
==
other1
);
CHECK
(
myNew2
->
output
(
0
).
at
(
0
).
first
==
other2
);
CHECK
(
graphTest
->
getNode
(
"old1"
)
==
nullptr
);
CHECK
(
graphTest
->
getNode
(
"old2"
)
==
nullptr
);
CHECK
(
graphTest
->
getNode
(
"new1"
)
==
myNew1
);
CHECK
(
graphTest
->
getNode
(
"new2"
)
==
myNew2
);
}
SECTION
(
"test case 2 multiple input, multiple output"
)
{
removeFile
(
"my_log.txt"
);
Log
::
setFileName
(
"my_log.txt"
);
Log
::
setFileLevel
(
Log
::
Level
::
Warn
);
std
::
vector
<
std
::
string
>
logs
;
std
::
shared_ptr
<
GraphView
>
graphTest
=
std
::
make_shared
<
GraphView
>
(
"test_graph"
);
auto
otherInput1
=
GenericOperator
(
"Producer"
,
{},
1
,
"other_input1"
);
auto
otherInput2
=
GenericOperator
(
"Producer"
,
{},
1
,
"other_input2"
);
auto
other11
=
GenericOperator
(
"Other"
,
{
InputCategory
::
Data
},
1
,
"other11"
);
auto
other12
=
GenericOperator
(
"Other"
,
{
InputCategory
::
Data
},
1
,
"other12"
);
auto
myOld11
=
GenericOperator
(
"Old"
,
{
InputCategory
::
Data
},
1
,
"old11"
);
auto
myOld12
=
GenericOperator
(
"Old"
,
{
InputCategory
::
Data
},
1
,
"old12"
);
auto
myOld21
=
GenericOperator
(
"Old"
,
{
InputCategory
::
Data
},
1
,
"old21"
);
auto
myOld22
=
GenericOperator
(
"Old"
,
{
InputCategory
::
Data
},
1
,
"old22"
);
auto
other21
=
GenericOperator
(
"Other"
,
{
InputCategory
::
Data
},
1
,
"other21"
);
auto
other22
=
GenericOperator
(
"Other"
,
{
InputCategory
::
Data
},
1
,
"other22"
);
otherInput1
->
addChild
(
other11
);
other11
->
addChild
(
myOld11
);
myOld11
->
addChild
(
myOld12
);
myOld12
->
addChild
(
other12
);
otherInput2
->
addChild
(
other11
);
other21
->
addChild
(
myOld21
);
myOld21
->
addChild
(
myOld22
);
myOld22
->
addChild
(
other22
);
graphTest
->
add
({
other11
,
myOld11
,
myOld12
,
other12
,
other21
,
myOld21
,
myOld22
,
other22
});
auto
myNew11
=
GenericOperator
(
"New"
,
{
InputCategory
::
Data
},
1
,
"new11"
);
auto
myNew12
=
GenericOperator
(
"New"
,
{
InputCategory
::
Data
},
1
,
"new12"
);
auto
myNew21
=
GenericOperator
(
"New"
,
{
InputCategory
::
Data
},
1
,
"new21"
);
auto
myNew22
=
GenericOperator
(
"New"
,
{
InputCategory
::
Data
},
1
,
"new22"
);
myNew11
->
addChild
(
myNew12
);
myNew21
->
addChild
(
myNew22
);
bool
retValue
=
GraphView
::
replace
({
myOld11
,
myOld12
,
myOld21
,
myOld22
},
{
myNew11
,
myNew12
,
myNew21
,
myNew22
});
CHECK
(
LoadTextFile
(
"my_log.txt"
,
logs
));
CHECK
(
logs
.
size
()
==
0
);
CHECK
(
graphTest
->
getNodes
()
==
std
::
set
<
std
::
shared_ptr
<
Node
>>
({
other11
,
myNew11
,
myNew12
,
other12
,
other21
,
myNew21
,
myNew22
,
other22
}));
graphTest
->
save
(
"myGraph"
,
true
,
true
);
CHECK
(
retValue
);
CHECK
(
myNew11
->
input
(
0
).
first
==
other11
);
CHECK
(
myNew12
->
output
(
0
).
at
(
0
).
first
==
other12
);
CHECK
(
myNew21
->
input
(
0
).
first
==
other21
);
CHECK
(
myNew22
->
output
(
0
).
at
(
0
).
first
==
other22
);
CHECK
(
graphTest
->
getNode
(
"old11"
)
==
nullptr
);
CHECK
(
graphTest
->
getNode
(
"old21"
)
==
nullptr
);
CHECK
(
graphTest
->
getNode
(
"old21"
)
==
nullptr
);
CHECK
(
graphTest
->
getNode
(
"old22"
)
==
nullptr
);
CHECK
(
graphTest
->
getNode
(
"new11"
)
==
myNew11
);
CHECK
(
graphTest
->
getNode
(
"new12"
)
==
myNew12
);
CHECK
(
graphTest
->
getNode
(
"new21"
)
==
myNew21
);
CHECK
(
graphTest
->
getNode
(
"new22"
)
==
myNew22
);
}
}
TEST_CASE
(
"[GraphView] clone"
)
{
auto
dataProvider
=
Producer
({
16
,
3
,
224
,
224
},
"dataProvider"
);
auto
conv1
=
Conv
(
3
,
32
,
{
3
,
3
},
"conv1"
);
...
...
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