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
dd13c2c2
Commit
dd13c2c2
authored
Jan 16, 2020
by
Wei Chen
Committed by
Tianqi Chen
Jan 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Relay][Op] Add type check to dense (#4724)
parent
13ffd989
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
src/relay/op/nn/nn.h
+5
-0
tests/python/relay/test_op_level1.py
+11
-0
No files found.
src/relay/op/nn/nn.h
View file @
dd13c2c2
...
...
@@ -57,6 +57,11 @@ bool DenseRel(const Array<Type>& types, int num_inputs, const Attrs& attrs,
}
else
{
if
(
weight
==
nullptr
)
return
false
;
Array
<
tvm
::
PrimExpr
>
wshape
=
weight
->
shape
;
CHECK
(
static_cast
<
int
>
(
weight
->
shape
.
size
())
==
2
);
CHECK
(
reporter
->
AssertEQ
(
data
->
shape
[
data
->
shape
.
size
()
-
1
],
weight
->
shape
[
1
]))
<<
"DenseRel: input dimension doesn't match,"
<<
" data shape="
<<
data
->
shape
<<
", weight shape="
<<
weight
->
shape
;
oshape
.
Set
((
oshape
.
size
()
-
1
),
wshape
[
0
]);
}
...
...
tests/python/relay/test_op_level1.py
View file @
dd13c2c2
...
...
@@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.
import
numpy
as
np
import
pytest
import
tvm
import
scipy
from
tvm
import
relay
...
...
@@ -336,6 +337,16 @@ def test_batch_norm():
relay
.
ty
.
TensorType
((
3
,),
dtype
)
]))
@pytest.mark.xfail
def
test_dense_type_check
():
dtype
=
'float16'
n
,
c
,
h
,
w
=
2
,
2
,
2
,
2
x
=
relay
.
var
(
"x"
,
relay
.
TensorType
((
n
,
c
,
h
,
w
),
dtype
))
# it should fail since it does not match with m(2)
mismatch_w
=
3
w
=
relay
.
var
(
"w"
,
relay
.
TensorType
((
2
,
mismatch_w
),
dtype
))
y
=
relay
.
nn
.
dense
(
x
,
w
)
yy
=
run_infer_type
(
y
)
def
test_dense
():
for
dtype
in
[
'float16'
,
'float32'
]:
...
...
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