Skip to content

Added GatherElements to Nuphar#2016

Merged
yangchen-MS merged 3 commits intomasterfrom
yanchen/nuphar/gather_elems
Oct 5, 2019
Merged

Added GatherElements to Nuphar#2016
yangchen-MS merged 3 commits intomasterfrom
yanchen/nuphar/gather_elems

Conversation

@yangchen-MS
Copy link
Contributor

This change added GatherElements (op_ver 11) to the Nuphar provider.

This change added GatherElements (op_ver 11) to the Nuphar provider.
@yangchen-MS yangchen-MS requested a review from a team as a code owner October 4, 2019 21:24
namespace tvm_codegen {

tvm::Tensor GatherElements(const tvm::Tensor& t,
int64_t axis,
Copy link
Contributor

Choose a reason for hiding this comment

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

axis [](start = 35, length = 4)

can this be negative? if not, maybe should use unsigned types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We always use int64_t for axis in other tensor apis. Seems it's better to follow the convention.

{"a", "a",
"d", "d"});
test4.Run(OpTester::ExpectResult::kExpectFailure, "GatherElements op: Value in indices must be within bounds [-2 , 1]. Actual value is -3");
// skip nuphar, which will not throw error message but will ensure no out-of-bound access
Copy link
Contributor

Choose a reason for hiding this comment

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

which will not throw error message but will ensure no out-of-bound access [](start = 18, length = 73)

I believe this should be the default behavior in ONNX spec for this op. Lots of devices won't be able to throw on invalid indices. Please open an issue to ONNX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

tvm::Expr real_idx = tvm::max(tvm::min(idx, idx_upper_bound - 1), 0) +
(idx < 0) * (idx_upper_bound + tvm::max(idx, -idx_upper_bound));
// tvm idx must be of Int(32)
ivars.push_back(tvm::cast(tvm::Int(32), real_idx));
Copy link
Contributor

@ke1337 ke1337 Oct 4, 2019

Choose a reason for hiding this comment

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

maybe better to make it a common util for index clamping, as other ops may reuse it too (Gather?) #Resolved

Copy link
Contributor Author

@yangchen-MS yangchen-MS Oct 4, 2019

Choose a reason for hiding this comment

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

Done. #Resolved

@ke1337 ke1337 requested a review from a team October 4, 2019 21:43
* create a utilify function for accessing index safely
}

// Make sure idx is within the range of [-bound, bound - 1]
tvm::Expr SafeIndex(const tvm::Expr& idx, const tvm::Expr& bound);
Copy link
Contributor

Choose a reason for hiding this comment

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

SafeIndex [](start = 10, length = 9)

Clamp index to be more exact

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks

return fixed_inputs;
}

// Make sure idx is within the range of [-bound, bound - 1]
Copy link
Contributor

Choose a reason for hiding this comment

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

within [](start = 20, length = 6)

clamped in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* SafeIndex -> ClampIndex
Copy link
Contributor

@ke1337 ke1337 left a comment

Choose a reason for hiding this comment

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

:shipit:

@yangchen-MS yangchen-MS merged commit e8285a7 into master Oct 5, 2019
@prasanthpul prasanthpul deleted the yanchen/nuphar/gather_elems branch May 16, 2021 18:37
yuslepukhin pushed a commit that referenced this pull request Mar 17, 2026
## Describe your changes
Adding OV recipes for Phi4, Phi4-mini-reasoning, several variants of
qwen2.5 instruct & qwen2.5 coder instruct, deepseek, and mistral.

## Checklist before requesting a review
- [ ] Add unit tests for this change.
- [ ] Make sure all tests can pass.
- [ ] Update documents if necessary.
- [ ] Lint and apply fixes to your code by running `lintrunner -a`
- [ ] Is this a user-facing change? If yes, give a description of this
change to be included in the release notes.
- [ ] Is this PR including examples changes? If yes, please remember to
update [example
documentation](https://github.com/microsoft/Olive/blob/main/docs/source/examples.md)
in a follow-up PR.

## (Optional) Issue link

---------

Co-authored-by: Anirudh Swaminathan <anirudh.swaminathan@intel.com>
Co-authored-by: Kaunain <kaunain.ahmed@intel.com>
Co-authored-by: kaunain-98 <108542306+kaunain-98@users.noreply.github.com>
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.

2 participants