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
3ae81914
Commit
3ae81914
authored
Jan 07, 2017
by
Eric Junyuan Xie
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enhance shape inference. allow in complete shape (#94)
parent
02396a7f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
8 deletions
+15
-8
nnvm/include/nnvm/tuple.h
+5
-0
nnvm/src/pass/infer_shape_type.cc
+10
-8
No files found.
nnvm/include/nnvm/tuple.h
View file @
3ae81914
...
...
@@ -387,6 +387,11 @@ class TShape : public Tuple<index_t> {
}
#ifdef MSHADOW_XINLINE
template
<
int
dim
>
inline
TShape
(
const
mshadow
::
Shape
<
dim
>
&
s
)
{
// NOLINT(*)
this
->
assign
(
s
.
shape_
,
s
.
shape_
+
dim
);
}
template
<
int
dim
>
inline
TShape
(
mshadow
::
Shape
<
dim
>
&&
s
)
{
// NOLINT(*)
this
->
assign
(
s
.
shape_
,
s
.
shape_
+
dim
);
}
...
...
nnvm/src/pass/infer_shape_type.cc
View file @
3ae81914
...
...
@@ -155,27 +155,29 @@ Graph InferAttr(Graph &&ret,
}
};
size_t
num_unknown
=
0
;
const
int
kMaxStep
=
3
;
for
(
int
i
=
0
;
i
<
kMaxStep
;
++
i
)
{
size_t
last_num_unknown
;
size_t
num_unknown
=
rshape
.
size
();
int
i
=
0
;
do
{
if
(
i
%
2
==
0
)
{
for
(
uint32_t
nid
=
0
;
nid
<
idx
.
num_nodes
();
++
nid
)
{
infer_step
(
nid
,
i
+
1
==
kMaxStep
);
infer_step
(
nid
,
false
);
}
}
else
{
// backward inference
for
(
uint32_t
i
=
idx
.
num_nodes
();
i
!=
0
;
--
i
)
{
infer_step
(
i
-
1
,
i
+
1
==
kMaxStep
);
infer_step
(
i
-
1
,
false
);
}
}
last_num_unknown
=
num_unknown
;
num_unknown
=
0
;
for
(
size_t
j
=
0
;
j
<
idx
.
num_node_entries
();
++
j
)
{
if
(
fis_none
(
rshape
[
j
]))
{
++
num_unknown
;
}
}
if
(
num_unknown
==
0
)
break
;
}
++
i
;
}
while
(
num_unknown
>
0
&&
last_num_unknown
>
num_unknown
);
// set the shapes
ret
.
attrs
[
attr_name
]
=
std
::
make_shared
<
any
>
(
std
::
move
(
rshape
));
// number of nodes who knows the shape.
...
...
@@ -190,7 +192,7 @@ NNVM_REGISTER_PASS(InferShape)
std
::
move
(
ret
),
TShape
(),
"FInferShape"
,
"shape_inputs"
,
"shape_attr_key"
,
"shape"
,
"shape_num_unknown_nodes"
,
[](
const
TShape
&
s
)
{
return
s
.
ndim
()
==
0
;
},
[](
const
TShape
&
s
)
{
return
s
.
ndim
()
==
0
||
s
.
Size
()
==
0
;
},
nullptr
);
})
.
set_change_graph
(
false
)
...
...
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