-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[relay][frontend] Enable ssd test by attaching schedules to multibox and ssd ops #2322
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ca4827c
add ssd ops to mxnet.py
zhiics 88d1bb0
add ssd ops to mxnet.py
zhiics 0bb928c
rebase
zhiics 859603c
add result check for multibox and nms unit tests
zhiics b5acdfc
add result check for multibox and nms unit tests
zhiics ef42daf
address @kevinthesun's comments
zhiics bce44b2
Disable cuda test for nms for now.
zhiics 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,3 +4,4 @@ | |
|
|
||
| from .multibox import * | ||
| from .nms import * | ||
| from . import _multibox | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # pylint: disable=invalid-name, unused-argument | ||
| """Definition of vision ops""" | ||
| from __future__ import absolute_import | ||
|
|
||
| import topi | ||
| from topi.util import get_const_int, get_const_float, get_float_tuple | ||
| from .. import op as reg | ||
| from ..op import OpPattern | ||
|
|
||
|
|
||
| @reg.register_schedule("vision.multibox_prior") | ||
| def schedule_multibox_prior(_, outs, target): | ||
| """Schedule definition of multibox_prior""" | ||
| with target: | ||
| return topi.generic.schedule_multibox_prior(outs) | ||
|
|
||
|
|
||
| @reg.register_compute("vision.multibox_prior") | ||
| def compute_multibox_prior(attrs, inputs, _, target): | ||
| """Compute definition of multibox_prior""" | ||
| sizes = get_float_tuple(attrs.sizes) | ||
| ratios = get_float_tuple(attrs.ratios) | ||
| steps = get_float_tuple(attrs.steps) | ||
| offsets = get_float_tuple(attrs.offsets) | ||
| clip = bool(get_const_int(attrs.clip)) | ||
| return [ | ||
| topi.vision.ssd.multibox_prior(inputs[0], sizes, ratios, steps, | ||
| offsets, clip) | ||
| ] | ||
|
|
||
|
|
||
| reg.register_pattern("vision.multibox_prior", OpPattern.OPAQUE) | ||
|
|
||
|
|
||
| # multibox_transform_loc | ||
| @reg.register_schedule("vision.multibox_transform_loc") | ||
| def schedule_multibox_transform_loc(_, outs, target): | ||
| """Schedule definition of multibox_detection""" | ||
| with target: | ||
| return topi.generic.schedule_multibox_transform_loc(outs) | ||
|
|
||
|
|
||
| @reg.register_compute("vision.multibox_transform_loc") | ||
| def compute_multibox_transform_loc(attrs, inputs, _, target): | ||
| """Compute definition of multibox_detection""" | ||
| clip = bool(get_const_int(attrs.clip)) | ||
| threshold = get_const_float(attrs.threshold) | ||
| variances = get_float_tuple(attrs.variances) | ||
| return topi.vision.ssd.multibox_transform_loc( | ||
| inputs[0], inputs[1], inputs[2], clip, threshold, variances) | ||
|
|
||
|
|
||
| reg.register_pattern("vision.multibox_transform_loc", OpPattern.OPAQUE) | ||
| reg.register_pattern("vision.multibox_detection", OpPattern.OPAQUE) | ||
|
|
||
|
|
||
| # non-maximum suppression | ||
| @reg.register_schedule("vision.nms") | ||
| def schedule_nms(_, outs, target): | ||
| """Schedule definition of nms""" | ||
| with target: | ||
| return topi.generic.schedule_nms(outs) | ||
|
|
||
|
|
||
| @reg.register_compute("vision.nms") | ||
| def compute_nms(attrs, inputs, _, target): | ||
| """Compute definition of nms""" | ||
| overlap_threshold = get_const_float(attrs.overlap_threshold) | ||
| force_suppress = bool(get_const_int(attrs.force_suppress)) | ||
| topk = get_const_int(attrs.topk) | ||
| return [ | ||
| topi.vision.nms(inputs[0], inputs[1], overlap_threshold, | ||
| force_suppress, topk) | ||
| ] | ||
|
|
||
|
|
||
| reg.register_pattern("vision.nms", OpPattern.OPAQUE) | ||
This file contains hidden or 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
Oops, something went wrong.
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.
This is not needed?
Uh oh!
There was an error while loading. Please reload this page.
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.
This is needed because
fcomputeneeds to receive an Array of Tensor when returning to c++. We can probably refactor the packfunc conversion a little bit to accept both Array and Tensor.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.
NNVM automatically wraps result in
Array:https://github.com/dmlc/tvm/blob/e5d92e1b96c1fbc175be741f522c030f2d91a613/nnvm/src/compiler/packed_func_ext.cc#L99-L103
But Relay does not:
https://github.com/dmlc/tvm/blob/e5d92e1b96c1fbc175be741f522c030f2d91a613/src/relay/ir/op.cc#L129-L135
Relay doc asks for schedule function that returns list. So this is indeed complying with existing Relay interface.