Skip to content

Optional extent checking on array dimensions #112

@M-Kusumgar

Description

@M-Kusumgar

Thank you for developing an awesome library! It would be useful to be able to toggle extent checking at runtime for testing. We have encountered a couple of rare problems with indices going past their extents but still mapping to a valid flat offset, such as a 2 x 3 x 4 tensor with index (3, 1, 1) in column major ordering that returns a flat offset of

3 + 1 * (2) + 1 * (2 * 3) = 11 (less than 2 * 3 * 4 = 24 so valid)

seems like it would be fairly easy to just add something like this below line 481

#ifdef NDA_BOUND_CHECKING
if (at - min_ >= extent_) {
  throw std::runtime_error(...)
}
#endif

to catch these greater than extent errors. Do you think this is reasonable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions