Skip to content

Commit

Permalink
added parallel node_context pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
nopeslide committed Mar 8, 2021
1 parent 5f971bf commit 60c8140
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/operators/operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct node_context {
Onnx__TensorProto **outputs;
operator_executer executer;
void *executer_context;
node_context *next;
bool threadsafe;
};

enum operator_status {
Expand Down
9 changes: 8 additions & 1 deletion src/inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@ Onnx__TensorProto** inference(Onnx__ModelProto *model, Onnx__TensorProto **input
for (int nodeIdx = 0; nodeIdx < model->graph->n_node; nodeIdx++)
{
TRACE(1, true, "Running node %d, operator=%s", nodeIdx, model->graph->node[nodeIdx]->op_type);
all_context[nodeIdx].executer(&all_context[nodeIdx]);
for (node_context *ctx = &all_context[nodeIdx]; ctx; ctx=ctx->next) {
if (!ctx->threadsafe) {
// wait for all threads to finish
}
// issue new thread
ctx->executer(ctx);
}
// wait for all threads to finish
}

// TODO
Expand Down

0 comments on commit 60c8140

Please sign in to comment.