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

[HEXAGON] Initial clip operator for Hexagon #11549

Merged
merged 36 commits into from
Jun 27, 2022

Conversation

jcoplin-quic
Copy link
Contributor

@jcoplin-quic jcoplin-quic commented Jun 2, 2022

This PR adds a basic Hexagon specific operator and test for clip. Clip is an elementwise operation to restricts an element between two values, min_value and max_value.

for element in data:
    element = max(min(element, max_value), min_value

This operator is useful for DeepLabv3.

cc @mehrdadh

@github-actions github-actions bot requested a review from mehrdadh June 2, 2022 18:42
@jcoplin-quic
Copy link
Contributor Author

@mehrdadh I'm seeing a segmentation fault in one of the CPU integration steps. Is this a known issue? If so is there a fix?

@jcoplin-quic
Copy link
Contributor Author

@TejashShah could you please assign some reviewers to this PR

@TejashShah
Copy link

cc @Lunderberg @cconvey @csullivan

@mehrdadh mehrdadh requested review from Lunderberg and csullivan June 14, 2022 21:34
@mehrdadh
Copy link
Member

@jcoplin-quic please add some detail to the PR description.

@jcoplin-quic
Copy link
Contributor Author

@mehrdadh I'm not sure why the tests are failing. Would you be able to provide any insight?

Copy link
Member

@mehrdadh mehrdadh left a comment

Choose a reason for hiding this comment

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

The error on ci_cpu is because of the missing fixture, but on ci_hexagon it has error on tests/python/contrib/test_hexagon/test_clip.py::TestClipSlice::test_clip_slice[nhwc-8h2w32c2w-2d-input_shape0-output_shape0-nhwc-8h2w32c2w-2d-float16-0.1-0.5]. That is introduced by the this PR.

@driazati
Copy link
Member

hey @jcoplin-quic, CI was busted when you pushed so the build never started, could you rebase/merge with main and push to your PR branch again?

Copy link
Contributor

@Lunderberg Lunderberg left a comment

Choose a reason for hiding this comment

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

Other than one nitpick, looks good to me!

# build the function
with tvm.transform.PassContext(opt_level=3):
func = tvm.build(
sch, [A, M], tvm.target.Target(target_hexagon, host=target_hexagon), name="clip"
Copy link
Contributor

Choose a reason for hiding this comment

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

The [A, M] argument can be removed. See comment here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Lunderberg removing this argument is causing the build to fail. It's not immediately evident to me why. Would you have any insight?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @jcoplin-quic, with TIR schedules you'll want to pass in the module, sch.mod, in which case you don't need the tensor list as @Lunderberg pointed out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, the IRModule should be passed to tvm.build, rather than the tvm.tir.Schedule. I've submitted #11913 to improve the error message, as I can definitely see the confusion when the error message doesn't distinguish between expected a te.Schedule or tir.Schedule.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @csullivan and @Lunderberg . At line 85, I assign tir_schedule.mod to sch. So sch should be IRModule, not tvm.tir.Schedule

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it had to do with optional argument target being treated as a positional argument

@kparzysz-quic kparzysz-quic merged commit cc6a85b into apache:main Jun 27, 2022
blackkker pushed a commit to blackkker/tvm that referenced this pull request Jul 7, 2022
* [HEXAGON] Initial clip operator for Hexagon

* Changes to utils and infra for pylint

* Remove unused import

* Use tvm.testing.main()

* Address pylint error

* Fix incorrect function call

* Changes to calls to transform_numpy

* Add newline at end of file

* Add requires_hexagon and rename under topi

* Whitespace fix and reduce input size

* Remove te tensor arguments

* Correct call to tvm.build

* Run black formatting
mikeseven pushed a commit to mikeseven/tvm that referenced this pull request Sep 27, 2023
* [HEXAGON] Initial clip operator for Hexagon

* Changes to utils and infra for pylint

* Remove unused import

* Use tvm.testing.main()

* Address pylint error

* Fix incorrect function call

* Changes to calls to transform_numpy

* Add newline at end of file

* Add requires_hexagon and rename under topi

* Whitespace fix and reduce input size

* Remove te tensor arguments

* Correct call to tvm.build

* Run black formatting
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.

7 participants