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
0ea59366
Commit
0ea59366
authored
1 year ago
by
Maxence Naud
Browse files
Options
Downloads
Patches
Plain Diff
[Upd] GraphView files
parent
5b042ee3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/aidge/graph/GraphView.hpp
+1
-1
1 addition, 1 deletion
include/aidge/graph/GraphView.hpp
src/graph/GraphView.cpp
+22
-20
22 additions, 20 deletions
src/graph/GraphView.cpp
with
23 additions
and
21 deletions
include/aidge/graph/GraphView.hpp
+
1
−
1
View file @
0ea59366
...
@@ -96,7 +96,7 @@ public:
...
@@ -96,7 +96,7 @@ public:
bool
inView
(
const
NodePtr
&
nodePtr
)
const
;
bool
inView
(
const
NodePtr
&
nodePtr
)
const
;
inline
NodePtr
getR
ootNode
()
const
noexcept
{
inline
NodePtr
r
ootNode
()
const
noexcept
{
return
mRootNode
;
return
mRootNode
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/graph/GraphView.cpp
+
22
−
20
View file @
0ea59366
...
@@ -9,11 +9,17 @@
...
@@ -9,11 +9,17 @@
*
*
********************************************************************************/
********************************************************************************/
#include
<algorithm>
#include
<algorithm>
// std::find, std::set_difference, std::set_intersection
#include
<cassert>
#include
<cassert>
#include
<iterator>
#include
<cstddef>
// std::size_t
#include
<utility>
#include
<cstdio>
// std::fopen, std::fprintf, std::fclose
#include
<numeric>
#include
<iterator>
// std::inserter, std::distance, std::next
#include
<map>
#include
<memory>
// std::shared_ptr, std::static_pointer_cast, std::make_shared
#include
<set>
#include
<string>
// std::to_string
#include
<utility>
// std::pair, std::make_pair
#include
<vector>
#include
"aidge/utils/Types.h"
#include
"aidge/utils/Types.h"
#include
"aidge/graph/GraphView.hpp"
#include
"aidge/graph/GraphView.hpp"
...
@@ -71,16 +77,12 @@ void Aidge::GraphView::save(std::string path, bool verbose, bool showProducers)
...
@@ -71,16 +77,12 @@ void Aidge::GraphView::save(std::string path, bool verbose, bool showProducers)
// Start by creating every node
// Start by creating every node
for
(
const
std
::
shared_ptr
<
Node
>
&
node_ptr
:
mNodes
)
{
for
(
const
std
::
shared_ptr
<
Node
>
&
node_ptr
:
mNodes
)
{
const
std
::
string
currentType
=
node_ptr
->
type
();
const
std
::
string
currentType
=
node_ptr
->
type
();
if
(
typeCounter
.
find
(
currentType
)
==
typeCounter
.
end
())
typeCounter
[
currentType
]
=
0
;
++
typeCounter
[
currentType
];
++
typeCounter
[
currentType
];
std
::
string
givenName
=
const
std
::
string
givenName
=
(
node_ptr
->
name
().
empty
())
?
(
node_ptr
->
name
().
empty
())
"<em>"
+
currentType
+
"#"
+
std
::
to_string
(
typeCounter
[
currentType
])
+
"</em>"
:
?
"<em>"
+
currentType
+
"#"
+
std
::
to_string
(
typeCounter
[
currentType
])
+
"</em>"
"
\"
"
+
node_ptr
->
name
()
+
"
\\
n<sub><em>( "
+
currentType
+
"#"
+
std
::
to_string
(
typeCounter
[
currentType
])
+
" )</em></sub>
\"
"
;
:
"
\"
"
+
node_ptr
->
name
()
+
"
\\
n<sub><em>( "
+
currentType
+
"#"
+
std
::
to_string
(
typeCounter
[
currentType
])
+
" )</em></sub>
\"
"
;
namePtrTable
[
node_ptr
]
=
(
currentType
+
"_"
+
std
::
to_string
(
typeCounter
[
currentType
]));
namePtrTable
[
node_ptr
]
=
(
currentType
+
"_"
+
std
::
to_string
(
typeCounter
[
currentType
]));
if
(
node_ptr
==
mRootNode
)
{
if
(
node_ptr
==
mRootNode
)
{
std
::
fprintf
(
fp
,
"%s(%s):::rootCls
\n
"
,
namePtrTable
[
node_ptr
].
c_str
(),
std
::
fprintf
(
fp
,
"%s(%s):::rootCls
\n
"
,
namePtrTable
[
node_ptr
].
c_str
(),
...
@@ -100,13 +102,13 @@ void Aidge::GraphView::save(std::string path, bool verbose, bool showProducers)
...
@@ -100,13 +102,13 @@ void Aidge::GraphView::save(std::string path, bool verbose, bool showProducers)
continue
;
continue
;
}
}
IOIndex_t
outputIdx
=
0
;
IOIndex_t
outputIdx
=
0
;
for
(
auto
childs
:
node_ptr
->
getOrderedChildren
())
{
for
(
const
auto
&
childs
:
node_ptr
->
getOrderedChildren
())
{
for
(
auto
child
:
childs
)
{
for
(
const
auto
&
child
:
childs
)
{
if
(
child
!=
nullptr
)
{
if
(
child
!=
nullptr
)
{
IOIndex_t
inputIdx
=
0
;
IOIndex_t
inputIdx
=
0
;
for
(
auto
parent
:
child
->
inputs
())
{
for
(
auto
parent
:
child
->
inputs
())
{
if
(
parent
.
first
==
node_ptr
&&
parent
.
second
==
outputIdx
)
{
if
(
parent
.
first
==
node_ptr
&&
parent
.
second
==
outputIdx
)
{
if
(
mNodes
.
find
(
child
)
!=
mNodes
.
end
())
{
if
(
mNodes
.
find
(
child
)
!=
mNodes
.
c
end
())
{
std
::
fprintf
(
fp
,
"%s-->|%u→%u|%s
\n
"
,
namePtrTable
[
node_ptr
].
c_str
(),
std
::
fprintf
(
fp
,
"%s-->|%u→%u|%s
\n
"
,
namePtrTable
[
node_ptr
].
c_str
(),
outputIdx
,
inputIdx
,
namePtrTable
[
child
].
c_str
());
outputIdx
,
inputIdx
,
namePtrTable
[
child
].
c_str
());
}
}
...
@@ -540,7 +542,7 @@ bool Aidge::GraphView::add(std::pair<NodePtr, std::set<NodePtr>> nodes, bool inc
...
@@ -540,7 +542,7 @@ bool Aidge::GraphView::add(std::pair<NodePtr, std::set<NodePtr>> nodes, bool inc
bool
Aidge
::
GraphView
::
add
(
std
::
shared_ptr
<
GraphView
>
graph
)
{
bool
Aidge
::
GraphView
::
add
(
std
::
shared_ptr
<
GraphView
>
graph
)
{
// set the rootNode to the other graphView rootNode if no rootNode yet
// set the rootNode to the other graphView rootNode if no rootNode yet
mRootNode
=
mRootNode
?
mRootNode
:
graph
->
getR
ootNode
();
mRootNode
=
mRootNode
?
mRootNode
:
graph
->
r
ootNode
();
return
add
(
graph
->
getNodes
(),
false
);
return
add
(
graph
->
getNodes
(),
false
);
}
}
...
@@ -741,10 +743,10 @@ bool Aidge::GraphView::replace(const std::set<Aidge::NodePtr>& oldNodes, const s
...
@@ -741,10 +743,10 @@ bool Aidge::GraphView::replace(const std::set<Aidge::NodePtr>& oldNodes, const s
auto
newG
=
std
::
make_shared
<
GraphView
>
(
"newG"
);
auto
newG
=
std
::
make_shared
<
GraphView
>
(
"newG"
);
newG
->
add
(
newNodes
,
false
);
newG
->
add
(
newNodes
,
false
);
const
auto
oldOI
=
oldG
->
getOrderedInputs
();
const
auto
&
oldOI
=
oldG
->
getOrderedInputs
();
const
auto
oldOO
=
oldG
->
getOrderedOutputs
();
const
auto
&
oldOO
=
oldG
->
getOrderedOutputs
();
const
auto
newOI
=
newG
->
getOrderedInputs
();
const
auto
&
newOI
=
newG
->
getOrderedInputs
();
const
auto
newOO
=
newG
->
getOrderedOutputs
();
const
auto
&
newOO
=
newG
->
getOrderedOutputs
();
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
inputParents
=
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
(
oldOI
.
size
());
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
inputParents
=
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
(
oldOI
.
size
());
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
outputChildren
=
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
(
oldOO
.
size
());
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
outputChildren
=
std
::
vector
<
std
::
pair
<
std
::
shared_ptr
<
Node
>
,
IOIndex_t
>>
(
oldOO
.
size
());
...
...
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