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

Add sliding_window operator #9816

Merged
merged 11 commits into from
Jan 12, 2022
Merged

Add sliding_window operator #9816

merged 11 commits into from
Jan 12, 2022

Conversation

gussmith23
Copy link
Contributor

Adds the windows operator, which slides a window over a tensor to produce a new tensor of all possible windows. This is an essential operation for implementing the im2col transformation, which transforms a conv2d into a matrix multiplication by constructing the windows over the activation tensor and storing them explicitly in memory.

This is the first time I've added an operator to TVM, so please let me know if I've missed anything. I am also happy to spend more time adding more tests and documentation.

@gussmith23 gussmith23 force-pushed the windows-operator branch 2 times, most recently from 1223395 to 2e2c9b1 Compare January 3, 2022 21:20
@gussmith23 gussmith23 marked this pull request as ready for review January 3, 2022 21:23
@gussmith23 gussmith23 changed the title [WIP] Add windows operator Add windows operator Jan 3, 2022
@gussmith23
Copy link
Contributor Author

Force-pushed to retrigger tests. Unsure why the test failed last time -- it failed on a seemingly unrelated test (an autotuner test).

Copy link
Contributor

@tkonolige tkonolige left a comment

Choose a reason for hiding this comment

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

I think you got all the things you needed for a new op. I don't know if you found it already, but I follow this guide: https://tvm.apache.org/docs/dev/how_to/relay_add_op.html.

include/tvm/topi/transform.h Outdated Show resolved Hide resolved
src/relay/op/tensor/transform.cc Outdated Show resolved Hide resolved
include/tvm/topi/transform.h Outdated Show resolved Hide resolved
@tkonolige
Copy link
Contributor

I do think having an example is useful.

@gussmith23
Copy link
Contributor Author

I was getting errors - - is there documentation on how to write examples? all the other examples in this file are rather simple, but to illustrate the use I think we need to use at least a relay executor and numpy random tensors. is that possible?

@tkonolige
Copy link
Contributor

Here's an example of using an example: https://github.com/apache/tvm/blob/main/python/tvm/relay/op/random/kernel.py#L59-L67. Examples are not run, so they don't necessarily need to be valid code.

@gussmith23
Copy link
Contributor Author

Oh, huh, i was getting this error:

/workspace/python/tvm/relay/__init__.py:docstring of tvm.relay.op.transform.windows:22: WARNING: Error in "code-block" directive:

maximum 1 argument(s) allowed, 51 supplied.



.. code-block:: python
    # Slide a window of shape (3, 4, 5) over the x tensor, beginning with
    <the rest of the example code>

I assumed this was because something was trying to run the Python code, which is why I removed the example. Turns out, I think it's because there was no newline after the .. code-block directive! The error message from Sphinx was a bit unintuitive. Let's see if adding a newline fixes things.

@gussmith23
Copy link
Contributor Author

Bump, ready for review by a code owner.

@masahi masahi self-assigned this Jan 9, 2022
@masahi
Copy link
Member

masahi commented Jan 9, 2022

I don't like the name "windows". How about sliding_window?

@gussmith23
Copy link
Contributor Author

@masahi done!

@gussmith23 gussmith23 changed the title Add windows operator Add sliding_window operator Jan 11, 2022
@masahi masahi merged commit 9160dc4 into apache:main Jan 12, 2022
Raghav-Chakravarthy pushed a commit to Raghav-Chakravarthy/tvm that referenced this pull request Jan 28, 2022
* Add windows operator

* remove TODO

* Convert ICHECKs to CHECKs

* Report errors using diagnostic context

* Use more readable CHECKs

* Remove example; move comments to test

* Revert "Remove example; move comments to test"

This is a partial revert.

This reverts commit c810c2d.

* Add newline to fix Sphinx error

* windows -> sliding_window

* whitespace

* fmt
ylc pushed a commit to ylc/tvm that referenced this pull request Feb 16, 2022
* Add windows operator

* remove TODO

* Convert ICHECKs to CHECKs

* Report errors using diagnostic context

* Use more readable CHECKs

* Remove example; move comments to test

* Revert "Remove example; move comments to test"

This is a partial revert.

This reverts commit c810c2d.

* Add newline to fix Sphinx error

* windows -> sliding_window

* whitespace

* fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants