Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
cld
ml
tvm
Commits
eb8077ff
Commit
eb8077ff
authored
7 years ago
by
Siva
Committed by
Tianqi Chen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[DEBUG] get_node_output : To retrieve out put of any node - for debug purpose. (#820)
parent
ba8d00c2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+4
-0
4 additions, 0 deletions
Makefile
make/config.mk
+3
-0
3 additions, 0 deletions
make/config.mk
python/tvm/contrib/graph_runtime.py
+21
-0
21 additions, 0 deletions
python/tvm/contrib/graph_runtime.py
src/runtime/graph/graph_runtime.cc
+47
-0
47 additions, 0 deletions
src/runtime/graph/graph_runtime.cc
with
75 additions
and
0 deletions
Makefile
+
4
−
0
View file @
eb8077ff
...
...
@@ -151,6 +151,10 @@ ifeq ($(USE_GRAPH_RUNTIME), 1)
RUNTIME_DEP
+=
$(
GRAPH_OBJ
)
endif
ifeq
($(USE_GRAPH_RUNTIME_DEBUG), 1)
CFLAGS
+=
-DTVM_GRAPH_RUNTIME_DEBUG
endif
include
make/contrib/cblas.mk
include
make/contrib/random.mk
include
make/contrib/nnpack.mk
...
...
This diff is collapsed.
Click to expand it.
make/config.mk
+
3
−
0
View file @
eb8077ff
...
...
@@ -50,6 +50,9 @@ USE_RPC = 1
# Whether enable tiny embedded graph runtime.
USE_GRAPH_RUNTIME
=
1
# Whether enable additional graph debug functions
USE_GRAPH_RUNTIME_DEBUG
=
0
# whether build with LLVM support
# Requires LLVM version >= 4.0
# Set LLVM_CONFIG to your version, uncomment to build with llvm support
...
...
This diff is collapsed.
Click to expand it.
python/tvm/contrib/graph_runtime.py
+
21
−
0
View file @
eb8077ff
...
...
@@ -72,6 +72,10 @@ class GraphModule(object):
self
.
_set_input
=
module
[
"
set_input
"
]
self
.
_run
=
module
[
"
run
"
]
self
.
_get_output
=
module
[
"
get_output
"
]
try
:
self
.
_debug_get_output
=
module
[
"
debug_get_output
"
]
except
AttributeError
:
pass
self
.
_load_params
=
module
[
"
load_params
"
]
self
.
ctx
=
ctx
...
...
@@ -121,6 +125,23 @@ class GraphModule(object):
self
.
_get_output
(
index
,
out
)
return
out
def
debug_get_output
(
self
,
node
,
out
):
"""
Run graph upto node and get the output to out
Parameters
----------
node : int / str
The node index or name
out : NDArray
The output array container
"""
if
hasattr
(
self
,
'
_debug_get_output
'
):
self
.
_debug_get_output
(
node
,
out
)
else
:
raise
RuntimeError
(
"
Please compile runtime with USE_GRAPH_RUNTIME_DEBUG = 0
"
)
return
out
def
load_params
(
self
,
params_bytes
):
"""
Load parameters from serialized byte array of parameter dict.
...
...
This diff is collapsed.
Click to expand it.
src/runtime/graph/graph_runtime.cc
+
47
−
0
View file @
eb8077ff
...
...
@@ -107,7 +107,44 @@ class GraphRuntime : public ModuleNode {
uint32_t
eid
=
this
->
entry_id
(
outputs_
[
index
]);
TVM_CCALL
(
TVMArrayCopyFromTo
(
&
data_entry_
[
eid
],
data_out
,
nullptr
));
}
#ifdef TVM_GRAPH_RUNTIME_DEBUG
/*!
* \brief Get the node index given the name of node.
* \param name The name of the node.
* \return The index of node.
*/
int
GetNodeIndex
(
const
std
::
string
&
name
)
{
for
(
uint32_t
nid
=
0
;
nid
<
nodes_
.
size
();
++
nid
)
{
if
(
nodes_
[
nid
].
name
==
name
)
{
return
static_cast
<
int
>
(
nid
);
}
}
LOG
(
FATAL
)
<<
"cannot find "
<<
name
<<
" among nodex"
;
return
-
1
;
}
/*!
* \brief Copy index-th node to data_out.
*
* This method will do a partial run of the the graph
* from begining upto the index-th node and return output of index-th node.
* This is costly operation and suggest to use only for debug porpose.
*
* \param index: The index of the node.
* \param data_out the node data.
*/
void
DebugGetNodeOutput
(
int
index
,
DLTensor
*
data_out
)
{
CHECK_LT
(
static_cast
<
size_t
>
(
index
),
nodes_
.
size
());
uint32_t
eid
=
index
;
for
(
size_t
i
=
0
;
i
<
op_execs_
.
size
();
++
i
)
{
if
(
static_cast
<
int
>
(
i
)
==
index
)
break
;
if
(
op_execs_
[
i
])
op_execs_
[
i
]();
}
TVM_CCALL
(
TVMArrayCopyFromTo
(
&
data_entry_
[
eid
],
data_out
,
nullptr
));
}
#endif
/*!
* \brief Load parameters from binary stream
* \param strm The input stream.
...
...
@@ -556,6 +593,16 @@ PackedFunc GraphRuntime::GetFunction(
return
PackedFunc
([
sptr_to_self
,
this
](
TVMArgs
args
,
TVMRetValue
*
rv
)
{
this
->
GetOutput
(
args
[
0
],
args
[
1
]);
});
#ifdef TVM_GRAPH_RUNTIME_DEBUG
}
else
if
(
name
==
"debug_get_output"
)
{
return
PackedFunc
([
sptr_to_self
,
this
](
TVMArgs
args
,
TVMRetValue
*
rv
)
{
if
(
args
[
0
].
type_code
()
==
kStr
)
{
this
->
DebugGetNodeOutput
(
this
->
GetNodeIndex
(
args
[
0
]),
args
[
1
]);
}
else
{
this
->
DebugGetNodeOutput
(
args
[
0
],
args
[
1
]);
}
});
#endif
}
else
if
(
name
==
"run"
)
{
return
PackedFunc
([
sptr_to_self
,
this
](
TVMArgs
args
,
TVMRetValue
*
rv
)
{
this
->
Run
();
...
...
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