Skip to content

Add "implementation consideration" about how out-of-bound indices of Gather/Scatter should be handled #486

@huningxin

Description

@huningxin

In proposal Add support for operations needed for well-known transformers , the validation steps of indices operand are defined as:

  1. Let axis be options.axis.
  2. Let axisSize be input.[[descriptor]].dimensions[axis]
  1. For each index → value of indices:
    i. If index is greater than or equal to axisSize, then throw a "DataError" DOMException.

The index value of indices operand may not be available at the graph build time, e.g., when indices is an input operand or an intermediate operand produced by another operator. It should define the run-time behavior if the index value of indices is greater than or equal to axisSize.

In that proposal, @wacky6 also recommended to add a "implementation consideration" (i.e. an informative section) mentioning how out-of-bound indices should be handled by browser vendor and platform implementation with some bullet points:

  • Runtime out-of-bounds indices should be explicitly handled by either the browser implementation or the platform implementation, to avoid OOB memory accesses.
  • If the platform implementation doesn't handle out-of-bounds indices, the browser implementation should take steps to ensure the platform operator doesn't receive out-of-bound indices
  • Mention what caller should expect as a result of list item 2: 0, NaN, first/last indices (if implemented with clamp)

/cc @anssiko @wchao1115 @fdwr

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions