ADRs/0022 - Dynamic Indexing.md
Discussion
Proposed by: Adam Gibson (30th April 2022)
Dynamic indexing has a wide variety of applications for building deep learning graphs.
Expressing a dynamic index that gets resolved at runtime entails specifying a negative index as the desired index for an indexing operation. At runtime, the indexing engine will then count backwards from the element the user specified. An example being: -1 starts at the end, -2 starts at the second to last.
Samediff and nd4j have numpy style indexing support.
Samediff does this 1 of 2 ways. Either through nd4j's indexing engine building on previous work or using a similar interface to nd4j's indexing engine to build a strided slice operation call. Previously, the indexing would not allow initialization with a negative index without passing in an ndarray. The problem with this is ndarrays are not known in samediff till execution time.
We support the ability to dynamically resolve indices during execution. This happens as follows: