Skip to content
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

[RELAY][OP]Strided slice #1891

Closed
wants to merge 5 commits into from

Conversation

siju-samuel
Copy link
Member

@siju-samuel siju-samuel commented Oct 12, 2018

#1799

Thanks for contributing to TVM! Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from others in the community.

@siju-samuel
Copy link
Member Author

TVM_ATTR_FIELD(begin)
.describe("Indices for begin of slice");
TVM_ATTR_FIELD(end)
.describe("Indices for end of the slice");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe inclusive, exclusive?

}

reporter->Assign(types[1], TensorTypeNode::make(oshape, data->dtype));
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undef min/max somewhere

@siju-samuel siju-samuel force-pushed the relay_strided_slice branch 3 times, most recently from 45efc2f to 32a2e69 Compare October 20, 2018 03:09
@tqchen
Copy link
Member

tqchen commented Oct 20, 2018

please rebase against master after #1934 to make use of the newly introduced API and add test-case to make sure text format works. Thanks!

@siju-samuel siju-samuel force-pushed the relay_strided_slice branch 5 times, most recently from 15b6a24 to 4e2edf7 Compare October 21, 2018 07:38
@tqchen tqchen added status: need review status: need update need update based on feedbacks and removed status: need review labels Oct 21, 2018
@siju-samuel siju-samuel force-pushed the relay_strided_slice branch 6 times, most recently from deb1df4 to 41b6e19 Compare October 27, 2018 03:43
@siju-samuel
Copy link
Member Author

@tqchen this can be merged? Anything else need to be done? can you please review once again and let me know. Thanks.

@tqchen
Copy link
Member

tqchen commented Oct 28, 2018

std::vector<IndexExpr> oshape(dshape.size());

for (size_t i = 0; i < num_axis; ++i) {
auto begin_range = reporter->Assert(stride_vec[i] < 0) ? -1 : 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using Assert here is not reliable, as if stride_vec is symbolic, then assert does not reflect anything.

@@ -122,6 +122,21 @@ struct SplitAttrs : public tvm::AttrsNode<SplitAttrs> {
}
};

/*! \brief Attributes for StridedSlice operator */
struct StridedSliceAttrs : public tvm::AttrsNode<StridedSliceAttrs> {
Array<IndexExpr> begin;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us change Array<IndexExpr> -> Array<Integer> for now, as integer is really what we can do reliably so far

struct StridedSliceAttrs : public tvm::AttrsNode<StridedSliceAttrs> {
Array<IndexExpr> begin;
Array<IndexExpr> end;
Array<IndexExpr> stride;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto begin = reporter->Assert(begin_vec[i] < 0) ? dshape[i] + begin_vec[i] : begin_vec[i];
auto end = reporter->Assert(end_vec[i] < 0) ? dshape[i] + end_vec[i] : end_vec[i];

begin = min(max(begin, begin_range), end_range);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use std::min std::max,

Copy link
Member Author

@siju-samuel siju-samuel Oct 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

begin and end is derived from dshape which is symbolic, so cannot use std::min/max

All other comments are fixed.

@@ -90,10 +90,31 @@ def test_reduce_functions():
verify_reduce(func, (128, 24, 128), (0, 2), False, False, (24,))
verify_reduce(func, (128, 24, 128), (0, 1), True, False, (1, 1, 128))
verify_reduce(func, (128, 24, 128), (0, 2), True, False, (1, 24, 1))
def verify_strided_slice(data, begin, end, stride, output):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline between functions

@siju-samuel siju-samuel force-pushed the relay_strided_slice branch 2 times, most recently from c9e48d3 to 3c3f641 Compare October 28, 2018 15:57
@tqchen
Copy link
Member

tqchen commented Nov 13, 2018

Given that there is still some gap and we need this OP in quickly, I am opening a followup #2094 which is based on this PR.

@tqchen tqchen closed this Nov 13, 2018
@tqchen
Copy link
Member

tqchen commented Nov 14, 2018

Thanks @siju-samuel @MarisaKirisame

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: need update need update based on feedbacks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants