Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
7cec28d5
Commit
7cec28d5
authored
7 years ago
by
dawehr
Browse files
Options
Downloads
Patches
Plain Diff
Few minor changes discussed in merge request
parent
f1a7683c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Add node to computation graph by ID
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
quad/src/computation_graph/computation_graph.c
+20
-16
20 additions, 16 deletions
quad/src/computation_graph/computation_graph.c
with
20 additions
and
16 deletions
quad/src/computation_graph/computation_graph.c
+
20
−
16
View file @
7cec28d5
...
...
@@ -11,9 +11,9 @@ static double exec_input_vals[GRAPH_MAX_INPUTS];
// Macro functions for setting and clearing single bits in int array
// From http://www.mathcs.emory.edu/~cheung/Courses/255/Syllabus/1-C-intro/bit-array.html
#define setBit(A,k) ( A[(k / (8*sizeof(
int
)))] |= (1 << (k % (8*sizeof(
int
)))) )
#define clearBit(A,k) ( A[(k / (8*sizeof(
int
)))] &= ~(1 << (k % (8*sizeof(
int
)))) )
#define testBit(A,k) ( A[(k / (8*sizeof(
int
)))] & (1 << (k % (8*sizeof(
int
)))) )
#define setBit(A,k) ( A[(k / (8*sizeof(
&A
)))] |= (1 << (k % (8*sizeof(
&A
)))) )
#define clearBit(A,k) ( A[(k / (8*sizeof(
&A
)))] &= ~(1 << (k % (8*sizeof(
&A
)))) )
#define testBit(A,k) ( A[(k / (8*sizeof(
&A
)))] & (1 << (k % (8*sizeof(
&A
)))) )
struct
computation_graph
*
create_graph
()
{
struct
computation_graph
*
the_graph
=
malloc
(
sizeof
(
struct
computation_graph
));
...
...
@@ -74,7 +74,8 @@ int graph_set_source(struct computation_graph *graph,
}
struct
graph_node
*
dest_node
=
&
graph
->
nodes
[
dest_node_id
];
struct
graph_node
*
src_node
=
&
graph
->
nodes
[
src_node_id
];
if
(
dest_input
>=
dest_node
->
type
->
n_inputs
||
src_output
>=
src_node
->
type
->
n_outputs
)
{
if
(
dest_input
>=
dest_node
->
type
->
n_inputs
||
src_output
>=
src_node
->
type
->
n_outputs
||
dest_input
<
0
||
src_output
<
0
)
{
return
-
1
;
}
...
...
@@ -182,14 +183,19 @@ double graph_get_output(const struct computation_graph *graph, int node_id, int
return
graph
->
nodes
[
node_id
].
output_values
[
output_id
];
}
/*
* Assumptions: The node passed in is a valid ID (should be checked before passing)
* and all node sources are either valid node-output pairs, or the source node ID == -1
* This function does not check those assumptions for speed
*/
void
graph_compute_node_rec
(
struct
computation_graph
*
graph
,
int
node_id
,
int
depth
)
{
if
(
depth
>=
GRAPH_MAX_DEPTH
)
{
assert
(
1
==
0
);
// TODO :Xil_Assert false
return
;
}
if
(
!
graph_node_exists
(
graph
,
node_id
))
{
assert
(
1
==
0
);
return
;
}
// if (!graph_node_exists(graph, node_id)) {
// return;
// }
struct
graph_node
*
node
=
&
graph
->
nodes
[
node_id
];
if
(
node
->
processed_state
!=
UNPROCESSED
)
{
return
;
...
...
@@ -226,9 +232,8 @@ void graph_compute_node_rec(struct computation_graph *graph, int node_id, int de
void
graph_compute_nodes
(
struct
computation_graph
*
graph
,
int
*
node_ids
,
int
n_nodes
)
{
int
i
;
for
(
i
=
0
;
i
<
graph
->
size
;
i
++
)
{
if
(
graph_node_exists
(
graph
,
i
))
{
graph
->
nodes
[
i
].
processed_state
=
UNPROCESSED
;
}
// Note: Do not access malloc'd members in here without first checking if node is valid
graph
->
nodes
[
i
].
processed_state
=
UNPROCESSED
;
}
for
(
i
=
0
;
i
<
n_nodes
;
i
++
)
{
int
node_id
=
node_ids
[
i
];
...
...
@@ -238,11 +243,10 @@ void graph_compute_nodes(struct computation_graph *graph, int* node_ids, int n_n
}
// Clear all the updated flags for nodes that were actually executed
for
(
i
=
0
;
i
<
graph
->
size
;
i
++
)
{
if
(
graph_node_exists
(
graph
,
i
))
{
struct
graph_node
*
node
=
&
graph
->
nodes
[
i
];
if
(
node
->
processed_state
==
PROCESSED
)
{
node
->
updated
=
0
;
}
// Note: Do not access malloc'd members in here without first checking if node is valid
struct
graph_node
*
node
=
&
graph
->
nodes
[
i
];
if
(
node
->
processed_state
==
PROCESSED
)
{
node
->
updated
=
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