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
ad28a0e8
Commit
ad28a0e8
authored
1 year ago
by
Maxence Naud
Browse files
Options
Downloads
Patches
Plain Diff
[Fix] replace() member function to run python tests successfully
parent
2e9f0013
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/utils/Recipies.hpp
+4
-1
4 additions, 1 deletion
include/aidge/utils/Recipies.hpp
src/graph/GraphView.cpp
+8
-5
8 additions, 5 deletions
src/graph/GraphView.cpp
unit_tests/graph/Test_GraphView.cpp
+39
-0
39 additions, 0 deletions
unit_tests/graph/Test_GraphView.cpp
with
51 additions
and
6 deletions
include/aidge/utils/Recipies.hpp
+
4
−
1
View file @
ad28a0e8
...
...
@@ -12,6 +12,9 @@
#ifndef AIDGE_CORE_UTILS_RECIPIES_H_
#define AIDGE_CORE_UTILS_RECIPIES_H_
#include
<memory>
#include
<set>
#include
"aidge/graph/Node.hpp"
#include
"aidge/graph/GraphView.hpp"
...
...
@@ -47,7 +50,7 @@ void removeFlatten(std::set<std::shared_ptr<Node>> nodes);
* @param graphView Graph view to use graph matching on, in order to apply transfomrations.
*/
void
removeFlatten
(
std
::
shared_ptr
<
GraphView
>
graphView
);
// FUSE BN + FC || CONV -> FC || CONV
/**
...
...
This diff is collapsed.
Click to expand it.
src/graph/GraphView.cpp
+
8
−
5
View file @
ad28a0e8
...
...
@@ -619,14 +619,17 @@ bool Aidge::GraphView::replace(const std::set<Aidge::NodePtr>& oldNodes, const s
for
(
auto
&
nodePtr
:
nodesToClean
)
{
nodePtr
->
resetConnections
(
true
);
}
// copy output connections
for
(
IOIndex_t
o
=
0
;
o
<
firstPreviousOutputNode
->
nbOutputs
();
++
o
)
{
auto
outputPairs
=
copyOutputs
[
o
];
for
(
const
auto
&
onePair
:
outputPairs
)
{
newOutputNode
->
addChild
(
onePair
.
first
,
o
,
onePair
.
second
);
if
(
newOutputNode
)
{
for
(
IOIndex_t
o
=
0
;
o
<
firstPreviousOutputNode
->
nbOutputs
();
++
o
)
{
auto
outputPairs
=
copyOutputs
[
o
];
for
(
const
auto
&
onePair
:
outputPairs
)
{
newOutputNode
->
addChild
(
onePair
.
first
,
o
,
onePair
.
second
);
}
}
}
// copy input connections
if
(
!
newNodes
.
empty
())
{
if
(
!
newNodes
.
empty
()
&&
externalInput
)
{
for
(
const
auto
&
newInputNode
:
newG
->
inputNodes
())
{
IOIndex_t
inputId
=
0
;
for
(
const
auto
&
input
:
newInputNode
->
inputs
())
{
...
...
This diff is collapsed.
Click to expand it.
unit_tests/graph/Test_GraphView.cpp
+
39
−
0
View file @
ad28a0e8
...
...
@@ -12,6 +12,7 @@
#include
<cassert>
#include
<map>
#include
<memory>
#include
<set>
#include
<string>
#include
<catch2/catch_test_macros.hpp>
...
...
@@ -419,6 +420,44 @@ TEST_CASE("[core/graph] GraphView(replace)", "[GraphView][replace]") {
REQUIRE
(
g
->
getNodes
()
==
std
::
set
<
std
::
shared_ptr
<
Node
>>
({
other1
,
myConv
,
other2
}));
}
SECTION
(
"Change every Nodes in a GraphView"
)
{
auto
matmulWeight0
=
GenericOperator
(
"Producer"
,
0
,
0
,
1
,
"matmul_w0"
);
auto
addBias0
=
GenericOperator
(
"Producer"
,
0
,
0
,
1
,
"add_b0"
);
auto
matmul0
=
GenericOperator
(
"MatMul"
,
1
,
2
,
1
,
"matmul0"
);
auto
add0
=
GenericOperator
(
"Add"
,
1
,
2
,
1
,
"add0"
);
auto
matmulWeight1
=
GenericOperator
(
"Producer"
,
0
,
0
,
1
,
"matmul_w1"
);
auto
addBias1
=
GenericOperator
(
"Producer"
,
0
,
0
,
1
,
"add_b1"
);
auto
matmul1
=
GenericOperator
(
"MatMul"
,
1
,
2
,
1
,
"matmul1"
);
auto
add1
=
GenericOperator
(
"Add"
,
1
,
2
,
1
,
"add1"
);
matmulWeight0
->
addChild
(
matmul0
,
0
,
1
);
addBias0
->
addChild
(
add0
,
0
,
1
);
matmulWeight1
->
addChild
(
matmul1
,
0
,
1
);
addBias1
->
addChild
(
add1
,
0
,
1
);
matmul0
->
addChild
(
add0
,
0
,
0
);
add0
->
addChild
(
matmul1
,
0
,
0
);
matmul1
->
addChild
(
add1
,
0
,
0
);
auto
g
=
std
::
make_shared
<
GraphView
>
(
"TestGraph"
);
g
->
add
({
matmulWeight0
,
addBias0
,
matmulWeight1
,
addBias1
,
matmul0
,
add0
,
matmul1
,
add1
});
auto
newMatmulWeight0
=
matmulWeight0
->
cloneSharedOperators
();
auto
newAddBias0
=
addBias0
->
cloneSharedOperators
();
auto
newMatmulWeight1
=
matmulWeight1
->
cloneSharedOperators
();
auto
newAddBias1
=
addBias1
->
cloneSharedOperators
();
auto
fc0
=
GenericOperator
(
"FC"
,
1
,
3
,
1
,
"fc0"
);
auto
fc1
=
GenericOperator
(
"FC"
,
1
,
3
,
1
,
"fc1"
);
newMatmulWeight0
->
addChild
(
fc0
,
0
,
1
);
newAddBias0
->
addChild
(
fc0
,
0
,
2
);
newMatmulWeight1
->
addChild
(
fc1
,
0
,
1
);
newAddBias1
->
addChild
(
fc1
,
0
,
2
);
GraphView
::
replace
({
matmul0
,
add0
,
matmulWeight0
,
addBias0
},
{
newMatmulWeight0
,
newAddBias0
,
fc0
});
GraphView
::
replace
({
matmul1
,
add1
,
matmulWeight1
,
addBias1
},
{
newMatmulWeight1
,
newAddBias1
,
fc1
});
REQUIRE
(
g
->
getNodes
()
==
std
::
set
<
std
::
shared_ptr
<
Node
>>
({
newMatmulWeight0
,
newAddBias0
,
newAddBias1
,
newMatmulWeight1
,
fc1
,
fc0
}));
}
}
TEST_CASE
(
"[GraphView] clone"
)
{
...
...
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