Skip to content

Import and extend c10/util/safe_numerics.h #11370

@JacobSzwejbka

Description

@JacobSzwejbka

🚀 The feature, motivation and pitch

Pytorch code referenced in title: https://github.com/pytorch/pytorch/blob/main/c10/util/safe_numerics.h

In #11217 we added a check for an overflow in nybtes. Rather then performing division every check itd be nicer if we had the faster checks in safe_numerics.h. There are probably other places in ET we should be checking for overflows like this.

safe_numerics.h currently only has int64 and uint64 so we'd need to extend it for size_t.

Could just write our own size_t form first and then resolve merging with pytorch/pytorch later.

cc @swolchok for suggesting it

Alternatives

No response

Additional context

No response

RFC (Optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions