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
3b6c66d1
Commit
3b6c66d1
authored
Mar 10, 2017
by
Ziheng Jiang
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable shape hints during infer_shape pass (#107)
* enable shape hints during infer_shape pass * fix comment
parent
96db41db
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
1 deletions
+48
-1
nnvm/include/nnvm/graph.h
+6
-0
nnvm/include/nnvm/node.h
+28
-0
nnvm/src/pass/infer_shape_type.cc
+14
-1
No files found.
nnvm/include/nnvm/graph.h
View file @
3b6c66d1
...
...
@@ -171,6 +171,12 @@ class IndexedGraph {
inline
const
std
::
vector
<
NodeEntry
>&
outputs
()
const
{
return
outputs_
;
}
/*! \return whether a node is existed in the indexed graph */
inline
bool
exist
(
const
nnvm
::
Node
*
node
)
const
{
return
node2index_
.
count
(
node
);
}
// disalllow copy assign
IndexedGraph
(
const
IndexedGraph
&
)
=
delete
;
...
...
nnvm/include/nnvm/node.h
View file @
3b6c66d1
...
...
@@ -42,6 +42,34 @@ struct NodeEntry {
};
/*!
* \brief This lets you use a NodeEntry as a key in a unordered_map of the form
* unordered_map<NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual>
*/
struct
NodeEntryHash
{
size_t
operator
()(
const
NodeEntry
&
e
)
const
{
return
std
::
hash
<
Node
*>
()(
e
.
node
.
get
())
^
(
std
::
hash
<
size_t
>
()(
e
.
index
)
<<
1
>>
1
)
^
(
std
::
hash
<
size_t
>
()(
e
.
version
)
<<
1
);
}
};
/*!
* \brief This lets you use a NodeEntry as a key in a unordered_map of the form
* unordered_map<NodeEntry, ValueType, NodeEntryHash, NodeEntryEqual>
*/
struct
NodeEntryEqual
{
size_t
operator
()(
const
NodeEntry
&
a
,
const
NodeEntry
&
b
)
const
{
return
(
a
.
node
.
get
()
==
b
.
node
.
get
())
&&
(
a
.
index
==
b
.
index
)
&&
(
a
.
version
==
b
.
version
);
}
};
/*! use NodeEntry as key in unordered_map */
template
<
typename
ValueType
>
using
NodeEntryMap
=
std
::
unordered_map
<
NodeEntry
,
ValueType
,
NodeEntryHash
,
NodeEntryEqual
>
;
/*!
* \brief The attributes of the current operation node.
* Usually are additional parameters like axis,
*/
...
...
nnvm/src/pass/infer_shape_type.cc
View file @
3b6c66d1
...
...
@@ -49,6 +49,19 @@ Graph InferAttr(Graph &&ret,
ret
.
attrs
.
erase
(
input_name
);
}
// get the shape hints
std
::
string
shape_hints_key
=
std
::
string
(
attr_name
)
+
"_hints"
;
if
(
ret
.
attrs
.
count
(
shape_hints_key
))
{
NodeEntryMap
<
AttrType
>
shape_hints
=
ret
.
GetAttr
<
NodeEntryMap
<
AttrType
>>
(
shape_hints_key
);
for
(
const
auto
&
kv
:
shape_hints
)
{
NodeEntry
e
=
kv
.
first
;
if
(
idx
.
exist
(
e
.
node
.
get
()))
{
rshape
[
idx
.
entry_id
(
kv
.
first
)]
=
kv
.
second
;
}
}
}
std
::
string
shape_attr_key
;
if
(
ret
.
attrs
.
count
(
attr_key_name
)
!=
0
)
{
shape_attr_key
=
ret
.
GetAttr
<
std
::
string
>
(
attr_key_name
);
...
...
@@ -75,7 +88,7 @@ Graph InferAttr(Graph &&ret,
CHECK
(
is
>>
rshape
[
out_ent_id
])
<<
"Invalid attribute"
;
}
}
}
else
if
(
is_backward
.
get
(
inode
.
source
->
op
(),
false
))
{
}
else
if
(
is_backward
.
get
(
inode
.
source
->
op
(),
false
)
&&
inode
.
control_deps
.
size
()
)
{
CHECK_GE
(
inode
.
control_deps
.
size
(),
1U
)
<<
"BackwardOp need to have control_deps to its forward op"
;
const
IndexedGraph
::
Node
&
fnode
=
idx
[
inode
.
control_deps
[
0
]];
...
...
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