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
43126602
Commit
43126602
authored
Sep 16, 2018
by
Zhennan Qin
Committed by
Tianqi Chen
Sep 15, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow inplace memory optimization for different data type (#1696)
parent
10ae8ee1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletions
+27
-1
nnvm/src/pass/plan_memory.cc
+27
-1
No files found.
nnvm/src/pass/plan_memory.cc
View file @
43126602
...
...
@@ -7,12 +7,37 @@
#include <nnvm/pass.h>
#include <nnvm/graph_attr_types.h>
#include <nnvm/op_attr_types.h>
#include <nnvm/top/tensor.h>
#include <memory>
#include "graph_algorithm.h"
namespace
nnvm
{
namespace
pass
{
namespace
{
using
namespace
nnvm
::
top
;
// Return bytes of data flag.
static
int
GetDTypeSize
(
int
type_flag
)
{
switch
(
type_flag
)
{
case
kUint8
:
case
kInt8
:
return
1
;
case
kFloat16
:
case
kInt16
:
case
kUint16
:
return
2
;
case
kFloat32
:
case
kInt32
:
case
kUint32
:
return
4
;
case
kFloat64
:
case
kInt64
:
case
kUint64
:
return
8
;
default:
LOG
(
FATAL
)
<<
"unknown type_flag="
<<
type_flag
;
return
-
1
;
}
}
// simple graph based allocator.
class
GraphAllocator
{
...
...
@@ -199,7 +224,8 @@ size_t AllocMemory(const Graph& ret, const IndexedGraph& idx,
((
storage_ref_count
[
sid_in
]
==
1
&&
!
ignore_all_inputs
)
||
identity
[
ipair
])
&&
entry_ref_count
[
eid_out
]
>
0
&&
shape_vec
[
eid_out
].
Size
()
==
shape_vec
[
eid_in
].
Size
()
&&
dtype_vec
[
eid_out
]
==
dtype_vec
[
eid_in
])
{
(
dtype_vec
[
eid_out
]
==
dtype_vec
[
eid_in
]
||
GetDTypeSize
(
dtype_vec
[
eid_out
])
==
GetDTypeSize
(
dtype_vec
[
eid_in
])))
{
// inplace optimization
taken
[
kv
.
first
]
=
true
;
storage
[
eid_out
]
=
sid_in
;
...
...
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