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
Iterations
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
Eclipse Projects
aidge
aidge_core
Commits
6fdf2ae6
Commit
6fdf2ae6
authored
1 year ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
More generic FuseMulAdd
parent
0350b632
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!105
version 0.2.0
,
!77
Support for recurrent networks
Pipeline
#40396
failed
1 year 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
src/recipes/FuseMulAdd.cpp
+29
-3
29 additions, 3 deletions
src/recipes/FuseMulAdd.cpp
with
29 additions
and
3 deletions
src/recipes/FuseMulAdd.cpp
+
29
−
3
View file @
6fdf2ae6
...
...
@@ -36,11 +36,37 @@ void Aidge::fuseMulAdd(std::shared_ptr<Aidge::Node> matmulNode, std::shared_ptr<
// Step 1 : Create FC
// Fetch the output dimension throught the bias size
std
::
shared_ptr
<
Node
>
bias
=
(
addNode
->
getParent
(
1
))
?
addNode
->
getParent
(
1
)
->
cloneSharedOperators
()
:
nullptr
;
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
();
}
else
if
(
addNode
->
getParent
(
1
)
==
matmulNode
)
{
AIDGE_ASSERT
(
matmulNode
->
getParent
(
0
),
"No bias detected to produce the fuseMulAdd recipe."
);
bias
=
addNode
->
getParent
(
0
)
->
cloneSharedOperators
();
}
AIDGE_ASSERT
(
matmulNode
->
getParent
(
1
),
"No weight detected to produce the fuseMulAdd recipe."
);
std
::
shared_ptr
<
Node
>
weight
=
nullptr
;
if
(
matmulNode
->
getParent
(
1
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
&&
matmulNode
->
getParent
(
0
)
->
getOperator
()
->
type
()
!=
Producer_Op
::
Type
)
{
weight
=
matmulNode
->
getParent
(
1
)
->
cloneSharedOperators
();
}
else
if
(
matmulNode
->
getParent
(
0
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
&&
matmulNode
->
getParent
(
1
)
->
getOperator
()
->
type
()
!=
Producer_Op
::
Type
)
{
weight
=
matmulNode
->
getParent
(
0
)
->
cloneSharedOperators
();
}
else
if
(
matmulNode
->
getParent
(
0
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
&&
matmulNode
->
getParent
(
1
)
->
getOperator
()
->
type
()
==
Producer_Op
::
Type
)
{
// If both inputs are producers, there is an ambiguity, but both options
// result in a correct solution.
fmt
::
print
(
"Warning: both MatMul inputs are Producers, assume data at input#0 and weights at input#1.
\n
"
);
weight
=
matmulNode
->
getParent
(
1
)
->
cloneSharedOperators
();
}
AIDGE_ASSERT
(
weight
!=
nullptr
,
"Could not deduce weight input for MatMul operator."
);
std
::
shared_ptr
<
Node
>
weight
=
matmulNode
->
getParent
(
1
)
->
cloneSharedOperators
();
// TODO: find another way to get OutChannels for FC operator.
// This poor fix supposes that one of Add inputs is a const and has the same outChannels as the output
DimSize_t
outSize
=
0
;
...
...
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