Skip to content

boolean indexing ops: AtenNonzeroOp, AtenIndexTensorOp, AtenMaskedSelectOp #3293

@renxida

Description

@renxida

Ops that need work:

AtenNonzeroOp, // creates a list of indices where a given tensor is nonzero
AtenIndexTensorOp, // currently only supports constant shape inputs / outputs & may not support boolean indices
AtenMaskedSelectOp, // no lowering. similar behavior to indexing with a boolean, but [flattens the output](https://discuss.pytorch.org/t/masked-select-vs-indexing-with-boolean-in-aten/33621/3)

All of the above ops decompose to indexing with a Boolean tensor

The key thing I can't figure out for these ops right now is that I really need a way to shorten something like

[0, 0, 1, 2, 0, 5, 8]

to

[1,2,5,8]

some kind of list filtering, basically.

If I have any one of the above ops, I would be able to decompose the rest to it. Indexing seems the most canonical choice.

How to implement bool indexing

I'm thinking just using a scf for loop to append to a list, then convert to a variable-length tensor. There are some nuances there and I should probably read this discussion with Ben and Quinn to figure it out https://discord.com/channels/973663919757492264/1172976577924050984/1220489866161295440

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions