-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Split and realdiv op support #2123
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -502,6 +502,83 @@ def test_forward_gather(): | |
_test_gather((4,3,5,6), (1,4), [[2,1,0,0]], 0, 'float32') | ||
|
||
|
||
####################################################################### | ||
# Split | ||
# ----- | ||
|
||
def _test_split(in_shape, axis, num_split, dtype): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add another test case with split followed by concat ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @srkreddy1238 updated |
||
""" One iteration of a Split """ | ||
|
||
with tf.Graph().as_default(): | ||
in_data = tf.placeholder(dtype, in_shape, name="in_data") | ||
tf.split(in_data, num_split, axis) | ||
np_data = np.random.uniform(size=in_shape).astype(dtype) | ||
compare_tf_with_tvm(np_data, 'in_data:0', 'split:0') | ||
|
||
def test_forward_split(): | ||
'''test split layer''' | ||
# rank 1 | ||
_test_split((3,), 0, 1, 'float32') | ||
_test_split((3,), 0, 3, 'float32') | ||
_test_split((6,), 0, 3, 'float32') | ||
# rank 2 | ||
_test_split((6, 2), 0, 3, 'float32') | ||
_test_split((2, 6), 1, 3, 'float32') | ||
# rank 3 | ||
_test_split((6, 2, 4), 0, 3, 'float32') | ||
_test_split((2, 6, 4), 1, 3, 'float32') | ||
_test_split((2, 4, 6), 2, 3, 'float32') | ||
# rank 4 | ||
_test_split((6, 1, 3, 5), 0, 3, 'float32') | ||
_test_split((1, 6, 3, 5), 1, 3, 'float32') | ||
_test_split((1, 3, 6, 5), 2, 3, 'float32') | ||
_test_split((1, 3, 5, 6), 3, 3, 'float32') | ||
# split along negative axis | ||
_test_split((6, 1, 3, 5), -4, 3, 'float32') | ||
_test_split((1, 6, 3, 5), -3, 3, 'float32') | ||
_test_split((1, 3, 6, 5), -2, 3, 'float32') | ||
_test_split((1, 3, 5, 6), -1, 3, 'float32') | ||
|
||
|
||
####################################################################### | ||
# Split followed by concat | ||
# ------------------------ | ||
|
||
def _test_split_concat(in_shape, axis, num_split, dtype): | ||
""" One iteration of a split_concat pair""" | ||
|
||
with tf.Graph().as_default(): | ||
in_data = tf.placeholder(dtype, in_shape, name="in_data") | ||
splitted = tf.split(in_data, num_split, axis) | ||
tf.concat(splitted, axis) | ||
np_data = np.random.uniform(size=in_shape).astype(dtype) | ||
compare_tf_with_tvm(np_data, 'in_data:0', 'concat:0') | ||
|
||
def test_forward_split_concat(): | ||
'''test split followed by concat layers''' | ||
# rank 1 | ||
_test_split_concat((3,), 0, 1, 'float32') | ||
_test_split_concat((3,), 0, 3, 'float32') | ||
_test_split_concat((6,), 0, 3, 'float32') | ||
# rank 2 | ||
_test_split_concat((6, 2), 0, 3, 'float32') | ||
_test_split_concat((2, 6), 1, 3, 'float32') | ||
# rank 3 | ||
_test_split_concat((6, 2, 4), 0, 3, 'float32') | ||
_test_split_concat((2, 6, 4), 1, 3, 'float32') | ||
_test_split_concat((2, 4, 6), 2, 3, 'float32') | ||
# rank 4 | ||
_test_split((6, 1, 3, 5), 0, 3, 'float32') | ||
_test_split((1, 6, 3, 5), 1, 3, 'float32') | ||
_test_split((1, 3, 6, 5), 2, 3, 'float32') | ||
_test_split((1, 3, 5, 6), 3, 3, 'float32') | ||
# split along negative axis | ||
_test_split((6, 1, 3, 5), -4, 3, 'float32') | ||
_test_split((1, 6, 3, 5), -3, 3, 'float32') | ||
_test_split((1, 3, 6, 5), -2, 3, 'float32') | ||
_test_split((1, 3, 5, 6), -1, 3, 'float32') | ||
|
||
|
||
####################################################################### | ||
# Multi Input to graph | ||
# -------------------- | ||
|
@@ -1061,6 +1138,8 @@ def test_forward_rel_ops(): | |
test_forward_pad() | ||
test_forward_gather() | ||
test_forward_stridedslice() | ||
test_forward_split() | ||
test_forward_split_concat() | ||
|
||
# Activations | ||
test_forward_sigmoid() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rasterer Can you explain this change ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refer to https://github.com/dmlc/tvm/blob/master/nnvm/src/top/nn/convolution.cc#L100 for the affect of dilation on output size. Dilated conv always can be simulated by a normal conv with dilated kernel. So I use dilated kernel size for pad calculation instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srkreddy1238 any more comment about this?