<p dir="auto">If you're coming from numpy you're used to be able to index and assign into arrays in the usual way.</p>
<p dir="auto">We should make our slicing and assignment ops more general to capture more of the functionality of numpy slicing, and add <code class="notranslate">__getitem__</code> sugar for all of it.  Specifically,</p>
<ol dir="auto">
<li>We should have a 2.5 dimensional set of ops, with dimensions (1) get vs. set, (2) slice type, and for the assignment ops (3) the update op.  Currently we have <code class="notranslate">slice</code>, <code class="notranslate">assign_update</code>, <code class="notranslate">assign_add</code>, <code class="notranslate">assign_sub</code>, <code class="notranslate">gather</code>, <code class="notranslate">scatter_update</code>, <code class="notranslate">scatter_add</code>, <code class="notranslate">scatter_sub</code>.  We should also have <code class="notranslate">assign_slice_update</code>, <code class="notranslate">assign_slice_add</code>, <code class="notranslate">assign_slice_sub</code>.</li>
<li>Both slicing and slice assignment should support strides, with no performance cost if strides aren't used.</li>
<li>Ideally, the slice ops should support negative indexing a la Python.  Since the slice parameters are already CPU, this is implementable with near zero cost.   The unfortunate bit is that since we picked the wrong format for specifying ranges (start + length instead of start : end), negative indexing might be awkward.  Thus, it might be best left to a separate bug.</li>
<li>Support numpy-like boolean indexing.</li>
<li>Generalize <code class="notranslate">gather</code> and <code class="notranslate">scatter_*</code> to take an array of input index tensors, efficiently broadcast them, and do multidimensional indexing similar to numpy.</li>
<li>Make <code class="notranslate">__getitem__</code> provide sugar for all of the above.  Ideally we'd have something idiomatically similar at least to <code class="notranslate">__setitem__</code>, but this is problematic since the returned assignment op is important to have, <code class="notranslate">__setitem__</code> does not return a value, and the nice range sugar is available only inside indexing / assignment calls.</li>
</ol>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/ebrevdo/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/ebrevdo">@ebrevdo</a>: I'm assigning this to you for now since you might get to it first, but feel free to grab only the piece of it that you need for now.</p>