Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
5a177070
Commit
5a177070
authored
Oct 21, 2019
by
Zhi
Committed by
Jared Roesch
Oct 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[relay][vm] Reuse allocated device memory (#4170)
parent
6f9d028b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
include/tvm/runtime/vm.h
+6
-0
src/runtime/vm/vm.cc
+12
-3
No files found.
include/tvm/runtime/vm.h
View file @
5a177070
...
...
@@ -747,6 +747,12 @@ class VirtualMachine : public runtime::ModuleNode {
/*! \brief The parameter name to data mapping. */
std
::
unordered_map
<
std
::
string
,
ObjectRef
>
params_
;
/*!
* \brief The constant pool for runtime. It caches the device dependent
* object to avoid rellocation of constants during inference.
*/
std
::
vector
<
ObjectRef
>
const_pool_
;
};
}
// namespace vm
...
...
src/runtime/vm/vm.cc
View file @
5a177070
...
...
@@ -795,9 +795,18 @@ void VirtualMachine::RunLoop() {
}
case
Opcode
:
:
LoadConst
:
{
auto
constant_obj
=
exec
->
constants
[
instr
.
const_index
];
// TODO(wweic) ctx could be obtained from the ctxs list.
auto
device_obj
=
CopyTo
(
constant_obj
,
ctxs
[
0
]);
WriteRegister
(
instr
.
dst
,
device_obj
);
// We cache the allocated object in the constant pool. To measure, the
// first iteration will set the pool up. The other iterations will
// directly reuse the allocated objects.
if
(
const_pool_
.
size
()
<=
static_cast
<
size_t
>
(
instr
.
const_index
))
{
const_pool_
.
resize
(
instr
.
const_index
+
1
);
}
if
(
!
const_pool_
[
instr
.
const_index
].
defined
())
{
// TODO(wweic) ctx could be obtained from the ctxs list.
const_pool_
[
instr
.
const_index
]
=
CopyTo
(
constant_obj
,
ctxs
[
0
]);
}
WriteRegister
(
instr
.
dst
,
const_pool_
[
instr
.
const_index
]);
pc
++
;
goto
main_loop
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment