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
c2b40c94
Commit
c2b40c94
authored
9 months ago
by
Olivier BICHLER
Browse files
Options
Downloads
Patches
Plain Diff
Working recipe
parent
fb245d4a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!152
Update Aidge export to take a graph view has an argument instead of a...
,
!131
New features to simplify exports
Pipeline
#47078
passed
9 months ago
Stage: static_analysis
Stage: build
Stage: test
Stage: coverage
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/aidge/recipes/Recipes.hpp
+8
-1
8 additions, 1 deletion
include/aidge/recipes/Recipes.hpp
src/recipes/FuseToMetaOps.cpp
+8
-3
8 additions, 3 deletions
src/recipes/FuseToMetaOps.cpp
unit_tests/recipes/Test_FuseToMetaOps.cpp
+19
-1
19 additions, 1 deletion
unit_tests/recipes/Test_FuseToMetaOps.cpp
with
35 additions
and
5 deletions
include/aidge/recipes/Recipes.hpp
+
8
−
1
View file @
c2b40c94
...
...
@@ -123,7 +123,14 @@ void explicitCastMove(std::shared_ptr<GraphView> graphView);
*/
void
expandMetaOps
(
std
::
shared_ptr
<
GraphView
>
graph
,
bool
recursive
=
false
);
void
fuseToMetaOps
(
std
::
shared_ptr
<
GraphView
>
graph
,
const
std
::
string
&
query
,
const
std
::
string
&
name
=
""
);
/**
* Fuse each sub-graph matching a query in a Meta Operator.
* @param graph Graph to manipulate
* @param query Sub-graph matching query
* @param type Type name of the resulting meta operators
* @return size_t Number of replacement
*/
size_t
fuseToMetaOps
(
std
::
shared_ptr
<
GraphView
>
graph
,
const
std
::
string
&
query
,
const
std
::
string
&
type
=
""
);
}
// namespace Aidge
...
...
This diff is collapsed.
Click to expand it.
src/recipes/FuseToMetaOps.cpp
+
8
−
3
View file @
c2b40c94
...
...
@@ -19,11 +19,13 @@
//Graph Regex
#include
"aidge/graphRegex/GraphRegex.hpp"
void
Aidge
::
fuseToMetaOps
(
std
::
shared_ptr
<
GraphView
>
graphView
,
const
std
::
string
&
query
,
const
std
::
string
&
nam
e
)
{
size_t
Aidge
::
fuseToMetaOps
(
std
::
shared_ptr
<
GraphView
>
graphView
,
const
std
::
string
&
query
,
const
std
::
string
&
typ
e
)
{
std
::
shared_ptr
<
GraphRegex
>
regex
=
std
::
make_shared
<
GraphRegex
>
();
regex
->
setKeyFromGraph
(
graphView
);
regex
->
addQuery
(
query
);
const
auto
metaType
=
(
!
type
.
empty
())
?
type
:
query
;
size_t
nbReplaced
=
0
;
const
auto
matches
=
regex
->
match
(
graphView
);
...
...
@@ -31,8 +33,10 @@ void Aidge::fuseToMetaOps(std::shared_ptr<GraphView> graphView, const std::strin
auto
microGraph
=
std
::
make_shared
<
GraphView
>
();
microGraph
->
add
(
solution
->
getAll
());
auto
metaOp
=
MetaOperator
(
query
.
c_str
(),
microGraph
,
name
);
const
auto
success
=
GraphView
::
replace
(
solution
->
getAll
(),
{
metaOp
});
auto
metaOp
=
MetaOperator
(
metaType
.
c_str
(),
microGraph
->
clone
());
auto
metaOpGraph
=
std
::
make_shared
<
GraphView
>
();
metaOpGraph
->
add
(
metaOp
);
const
auto
success
=
GraphView
::
replace
(
microGraph
,
metaOpGraph
);
if
(
!
success
)
{
Log
::
notice
(
"Could not replace sub-graph with meta operator"
);
...
...
@@ -43,4 +47,5 @@ void Aidge::fuseToMetaOps(std::shared_ptr<GraphView> graphView, const std::strin
}
Log
::
info
(
"Replaced {} (out of {}) matching sub-graph with meta operators"
,
nbReplaced
,
matches
.
size
());
return
nbReplaced
;
}
This diff is collapsed.
Click to expand it.
unit_tests/recipes/Test_FuseToMetaOps.cpp
+
19
−
1
View file @
c2b40c94
...
...
@@ -14,13 +14,31 @@
#include
"aidge/data/Tensor.hpp"
#include
"aidge/graph/GraphView.hpp"
#include
"aidge/graph/OpArgs.hpp"
#include
"aidge/operator/Conv.hpp"
#include
"aidge/operator/ReLU.hpp"
#include
"aidge/operator/Producer.hpp"
#include
"aidge/recipes/Recipes.hpp"
namespace
Aidge
{
TEST_CASE
(
"[cpu/recipes] FuseToMetaOps"
,
"[FuseToMetaOps][recipes]"
)
{
auto
g1
=
Sequential
({
Producer
({
16
,
3
,
224
,
224
},
"dataProvider"
),
Conv
(
3
,
32
,
{
3
,
3
},
"conv1"
),
ReLU
(
"relu1"
),
Conv
(
32
,
64
,
{
3
,
3
},
"conv2"
),
ReLU
(
"relu2"
),
Conv
(
64
,
10
,
{
1
,
1
},
"conv3"
)
});
g1
->
save
(
"FuseToMetaOps_before"
);
// FIXME: GraphRegex also matches the Conv Producers, which are not in the query!
const
auto
nbFused
=
fuseToMetaOps
(
g1
,
"Conv->ReLU"
,
"ConvReLU"
);
g1
->
save
(
"FuseToMetaOps_after"
,
true
);
REQUIRE
(
nbFused
==
2
);
}
}
// namespace Aidge
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