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
30781475
Commit
30781475
authored
1 year ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue with fuseMulAdd
parent
837bead8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/recipes/FuseMulAdd.cpp
+9
-9
9 additions, 9 deletions
src/recipes/FuseMulAdd.cpp
with
9 additions
and
9 deletions
src/recipes/FuseMulAdd.cpp
+
9
−
9
View file @
30781475
...
...
@@ -39,11 +39,11 @@ void Aidge::fuseMulAdd(std::shared_ptr<Aidge::Node> matmulNode, std::shared_ptr<
std
::
shared_ptr
<
Node
>
bias
=
nullptr
;
if
(
addNode
->
getParent
(
0
)
==
matmulNode
)
{
AIDGE_ASSERT
(
matmulNode
->
getParent
(
1
),
"No bias detected to produce the fuseMulAdd recipe."
);
bias
=
addNode
->
getParent
(
1
)
->
cloneSharedOperators
()
;
bias
=
addNode
->
getParent
(
1
);
}
else
if
(
addNode
->
getParent
(
1
)
==
matmulNode
)
{
AIDGE_ASSERT
(
matmulNode
->
getParent
(
0
),
"No bias detected to produce the fuseMulAdd recipe."
);
bias
=
addNode
->
getParent
(
0
)
->
cloneSharedOperators
()
;
bias
=
addNode
->
getParent
(
0
);
}
std
::
shared_ptr
<
Node
>
weight
=
nullptr
;
...
...
@@ -51,13 +51,13 @@ void Aidge::fuseMulAdd(std::shared_ptr<Aidge::Node> matmulNode, std::shared_ptr<
||
(
matmulNode
->
getParent
(
1
)
&&
matmulNode
->
getParent
(
1
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
&&
matmulNode
->
getParent
(
0
)
&&
matmulNode
->
getParent
(
0
)
->
getOperator
()
->
type
()
!=
Producer_Op
::
Type
))
{
weight
=
matmulNode
->
getParent
(
1
)
->
cloneSharedOperators
()
;
weight
=
matmulNode
->
getParent
(
1
);
}
else
if
((
matmulNode
->
getParent
(
0
)
&&
!
matmulNode
->
getParent
(
1
))
||
(
matmulNode
->
getParent
(
0
)
&&
matmulNode
->
getParent
(
0
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
&&
matmulNode
->
getParent
(
1
)
&&
matmulNode
->
getParent
(
1
)
->
getOperator
()
->
type
()
!=
Producer_Op
::
Type
))
{
weight
=
matmulNode
->
getParent
(
0
)
->
cloneSharedOperators
()
;
weight
=
matmulNode
->
getParent
(
0
);
}
else
if
(
matmulNode
->
getParent
(
0
)
&&
matmulNode
->
getParent
(
0
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
&&
matmulNode
->
getParent
(
1
)
&&
matmulNode
->
getParent
(
1
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
)
...
...
@@ -65,7 +65,7 @@ void Aidge::fuseMulAdd(std::shared_ptr<Aidge::Node> matmulNode, std::shared_ptr<
// If both inputs are producers, there is an ambiguity, but both options
// result in a correct solution.
Log
::
notice
(
"Notice: both MatMul inputs are Producers, assume data at input#0 and weights at input#1."
);
weight
=
matmulNode
->
getParent
(
1
)
->
cloneSharedOperators
()
;
weight
=
matmulNode
->
getParent
(
1
);
}
AIDGE_ASSERT
(
weight
!=
nullptr
,
"Could not deduce weight input for MatMul operator."
);
...
...
@@ -90,9 +90,9 @@ void Aidge::fuseMulAdd(std::shared_ptr<Aidge::Node> matmulNode, std::shared_ptr<
// Step 2 : Branch existing producers & create the others
// link weights & bias
weight
->
addChild
(
fc
,
0
,
1
);
weight
->
cloneSharedOperators
()
->
addChild
(
fc
,
0
,
1
);
if
(
bias
)
{
bias
->
addChild
(
fc
,
0
,
2
);
bias
->
cloneSharedOperators
()
->
addChild
(
fc
,
0
,
2
);
}
...
...
@@ -100,8 +100,8 @@ void Aidge::fuseMulAdd(std::shared_ptr<Aidge::Node> matmulNode, std::shared_ptr<
// Case 1 : If all nodes are in a graph view : delete old nodes & branch input & output
// Case 2 : If not all nodes are in a graph view : only delete the nodes from the graphview
// Maybe create a central mechanism to update automatically all graph views rather than each node have graphview presence memory?
auto
newNodes
=
std
::
set
<
std
::
shared_ptr
<
Node
>>
({
fc
,
weight
,
fc
->
getParent
(
2
)});
GraphView
::
replace
({
matmulNode
,
addNode
,
addNode
->
getParent
(
1
),
matmulNode
->
getParent
(
1
)
},
newNodes
);
auto
newNodes
=
std
::
set
<
std
::
shared_ptr
<
Node
>>
({
fc
,
fc
->
getParent
(
1
)
,
fc
->
getParent
(
2
)});
GraphView
::
replace
({
matmulNode
,
addNode
,
bias
,
weight
},
newNodes
);
}
...
...
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