Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 276 additions & 4 deletions AGENTS.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/src/main/scala/dimwit/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ package object dimwit:
val name: String = s"${labelA.name}+${labelB.name}"

// Export tensor and related types
export dimwit.tensor.{Tensor, Tensor0, Tensor1, Tensor2, Tensor3, Tensor4, TypedIndex}
export dimwit.tensor.{Tensor, Tensor0, Tensor1, Tensor2, Tensor3, Tensor4, ElementIndex, Idx}
export dimwit.tensor.{Shape, Shape0, Shape1, Shape2, Shape3}
export dimwit.tensor.DType
export dimwit.tensor.DType.{BFloat16, Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, Bool}
Expand Down
5 changes: 2 additions & 3 deletions core/src/main/scala/dimwit/random/Random.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package dimwit.random
import dimwit.tensortree.TensorTree
import dimwit.jax.Jax
import dimwit.python.PyBridge.liftPyTensor
import dimwit.tensor.DType.Int32
import dimwit.*
import dimwit.tensor.TupleHelpers.TupleNOf
import dimwit.tensor.*
Expand Down Expand Up @@ -81,9 +80,9 @@ object Random:
* @param key
* The random key
* @return
* A 1D tensor containing a random permutation of [0, 1, ..., n-1]
* A random permutation of the positions [0, 1, ..., n-1] along the axis
*/
def permutation[L: Label](dim: AxisExtent[L])(key: Key): Tensor1[L, Int32] =
def permutation[L: Label](dim: AxisExtent[L])(key: Key): Tensor1[L, Idx[L]] =
liftPyTensor(Jax.jrandom.permutation(key.jaxKey, dim.size))

object Key:
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/scala/dimwit/stats/UnivariateDistributions.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dimwit.stats

import dimwit.DType.Float32
import dimwit.DType.Int32
import dimwit.*
import dimwit.jax.Jax
import dimwit.python.PyBridge.liftPyTensor
Expand All @@ -14,17 +13,18 @@ import dimwit.python.PyBridge.liftPyTensor
*/
type UnivariateDistribution[V] = Distribution[EmptyTuple, V]

class Categorical[L: Label](val probs: Tensor1[L, Prob]) extends UnivariateDistribution[Int32]:
/** Distribution over the positions along the axis `L`, with the probability of each position given by `probs`. */
class Categorical[L: Label](val probs: Tensor1[L, Prob]) extends UnivariateDistribution[Idx[L]]:

private val logProbs: Tensor1[L, LogProb] = probs.log

override def logProb(x: Tensor0[Int32]): Tensor0[LogProb] =
// JAX clamps out-of-range indices (and wraps negative ones), so values outside 0..K-1 are masked explicitly
val indexed: Tensor0[LogProb] = liftPyTensor(logProbs.jaxValue.__getitem__(x.jaxValue))
val inRange = (x >= Tensor0(0)) and (x < Tensor0(probs.shape.dimensions(0)))
override def logProb(x: Tensor0[Idx[L]]): Tensor0[LogProb] =
val i = x.asInt32
val indexed: Tensor0[LogProb] = liftPyTensor(logProbs.jaxValue.__getitem__(i.jaxValue))
val inRange = (i >= Tensor0(0)) and (i < Tensor0(probs.shape.dimensions(0)))
where(inRange, indexed, LogProb(Tensor0(Float.NegativeInfinity)))

override def sample(key: Key): Tensor0[Int32] =
override def sample(key: Key): Tensor0[Idx[L]] =
liftPyTensor(Jax.jrandom.categorical(key.jaxKey, logProbs.jaxValue))

object Categorical:
Expand Down
25 changes: 18 additions & 7 deletions core/src/main/scala/dimwit/tensor/Axis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@ import scala.annotation.targetName
/** Instances of this class represent an axis in a tensor with a specific label `L`.
* Axis objects are used whenever an axis needs to be selected at the value level,
* such as when indexing into a tensor or defining the shape of a tensor.
*
* Positions given as tensors use the index type. Whenever they are Scala literals
* (plain number, range, ...) they are plain integers
*/
final class Axis[L: Label]:
def extent(size: Int): AxisExtent[L] = AxisExtent(this, size)
def ->(size: Int): AxisExtent[L] = this.extent(size)
def at(index: Int): AxisAtIndex[L] = AxisAtIndex(this, index)
def at(index: Tensor0[Int32]): AxisAtTensorIndex[L] = AxisAtTensorIndex(this, index)
@targetName("atIdx")
def at(index: Tensor0[Idx[L]]): AxisAtTensorIndex[L] = AxisAtTensorIndex(this, index.asType(VType[Int32]))
@targetName("atIdxIndices")
def at[L2](indices: Tensor1[L2, Idx[L]]): AxisAtTensorIndices[L, L2] = AxisAtTensorIndices(this, indices)

def at(range: Range): AxisAtRange[L] = AxisAtRange(this, range)
def at(indices: Seq[Int]): AxisAtIndices[L] = AxisAtIndices(this, indices)
def at(index: Tensor0[Int32]): AxisAtTensorIndex[L] = AxisAtTensorIndex(this, index)
@targetName("atTensorIndices")
def at[L2](indices: Tensor1[L2, Int32]): AxisAtTensorIndices[L, L2] = AxisAtTensorIndices(this, indices)
def at(start: Int, windowSize: Int): AxisAtWindow[L] = AxisAtWindow(this, start, windowSize)
def at(start: Tensor0[Int32], windowSize: Int): AxisAtWindow[L] = AxisAtWindow(this, start, windowSize)

/** Window of `windowSize` positions starting at a position along this axis. */
@targetName("atIdxWindow")
def at(start: Tensor0[Idx[L]], windowSize: Int): AxisAtWindow[L] = AxisAtWindow(this, start.asType(VType[Int32]), windowSize)
def at[I <: NonEmptyTuple](indices: I): AxisAtTupleIndices[L, I] = AxisAtTupleIndices(this, indices)
def as[U](newAxis: Axis[U]): (Axis[L], Axis[U]) = (this, newAxis)

Expand All @@ -36,9 +46,10 @@ case class AxisExtent[L: Label](axis: Axis[L], size: Int):
def *[L2: Label](other: AxisExtent[L2]): AxisExtent[L |*| L2] =
AxisExtent(Axis[L |*| L2], size * other.size)

/** Provides typed access to the indices. I.e. the user can write `idx(Axis[A])` to get the index along axis A.
/** The position of an element in all axes of `T`, as passed to `fromFunction`: `idx(Axis[A])` is its position along A.
* It lives on the Scala side; for positions held in a tensor see [[Idx]].
*/
class TypedIndex[T <: Tuple](private[dimwit] val coordInts: IndexedSeq[Int]):
class ElementIndex[T <: Tuple](private[dimwit] val coordInts: IndexedSeq[Int]):
def apply[L](axis: Axis[L])(using ev: AxisIndex[T, L]): Int =
coordInts(ev.index)

Expand All @@ -60,8 +71,8 @@ case class AxisAtIndices[L](axis: Axis[L], indices: Seq[Int]) extends AxisSelect
/* Represent an axis selection by a tensor containing indices. This allows for dynamic indexing based on the contents of the tensor. */
case class AxisAtTensorIndex[L](axis: Axis[L], index: Tensor0[Int32]) extends AxisSelector[L]

/* Represent an axis selection by a vector of indices. The selected axis is replaced by the axis of the vector. */
case class AxisAtTensorIndices[L, L2](axis: Axis[L], indices: Tensor1[L2, Int32]) extends AxisSelector[L]
/* Represent an axis selection by a vector of positions along the axis. The selected axis is replaced by the axis of the vector. */
case class AxisAtTensorIndices[L, L2](axis: Axis[L], indices: Tensor1[L2, Idx[L]]) extends AxisSelector[L]

/** Represent an axis selection by a window of `windowSize` consecutive indices from `start`.
* The start may be a tensor, also a traced one (e.g. a loop index under `jit`); the size is static.
Expand Down
30 changes: 30 additions & 0 deletions core/src/main/scala/dimwit/tensor/Idx.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package dimwit.tensor

import dimwit.jax.Jax
import dimwit.tensor.DType.Int32
import dimwit.tensor.ValueTypeClasses.IsIndex

/** The value type Idx[L] of positions along the axis with label `L`.
* This is used to distinguish plain int32 from indices. It also stores the axis to
* which this index applies. Thus it allows for type level checks.
*/
sealed trait Idx[L]

object Idx:

/* An index is currently only defined for Int#2 */
given isIndex[L]: IsIndex[Idx[L]] with
def dtype: DType = DType.Int32

/* The scala type of an index is a Scala Int */
given hasScalar[L]: HasScalar[Idx[L], Int] with
def readFlat(jv: Jax.PyDynamic): Array[Int] = ArrayReader.readIntArray(jv)
def classTag: scala.reflect.ClassTag[Int] = scala.reflect.ClassTag.Int

/** Create an Index for the given axis */
def apply[L](axis: Axis[L])(index: Int): Tensor0[Idx[L]] =
Tensor(Jax.jnp.array(index, dtype = Jax.jnp.int32))

/** Interprets the integers of `t` as positions along the axis `L`. */
def fromInt32[T <: Tuple: Labels, L](axis: Axis[L])(t: Tensor[T, Int32]): Tensor[T, Idx[L]] =
t.asType(VType[Idx[L]])
20 changes: 10 additions & 10 deletions core/src/main/scala/dimwit/tensor/Tensor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import dimwit.tensor.ValueTypeClasses.IsBoolean
import dimwit.tensor.ValueTypeClasses.IsFloating
import dimwit.tensor.ValueTypeClasses.IsInteger
import dimwit.tensor.ValueTypeClasses.IsNumber
import dimwit.tensor.TypedIndex
import dimwit.tensor.ElementIndex
import dimwit.tensor.VType
import me.shadaj.scalapy.py
import me.shadaj.scalapy.py.SeqConverters
Expand Down Expand Up @@ -113,25 +113,25 @@ object Tensor:
* using the provided function.
*/
@targetName("fromFunctionFloat")
def fromFunction(f: TypedIndex[T] => Float): Tensor[T, Float32] =
def fromFunction(f: ElementIndex[T] => Float): Tensor[T, Float32] =
Tensor(shape, VType[Float32]).fromArray(Tensor.tabulate(shape.dimensions, f))
@targetName("fromFunctionDouble")
def fromFunction(f: TypedIndex[T] => Double): Tensor[T, Float64] =
def fromFunction(f: ElementIndex[T] => Double): Tensor[T, Float64] =
Tensor(shape, VType[Float64]).fromArray(Tensor.tabulate(shape.dimensions, f))
@targetName("fromFunctionByte")
def fromFunction(f: TypedIndex[T] => Byte): Tensor[T, Int8] =
def fromFunction(f: ElementIndex[T] => Byte): Tensor[T, Int8] =
Tensor(shape, VType[Int8]).fromArray(Tensor.tabulate(shape.dimensions, f))
@targetName("fromFunctionShort")
def fromFunction(f: TypedIndex[T] => Short): Tensor[T, Int16] =
def fromFunction(f: ElementIndex[T] => Short): Tensor[T, Int16] =
Tensor(shape, VType[Int16]).fromArray(Tensor.tabulate(shape.dimensions, f))
@targetName("fromFunctionInt")
def fromFunction(f: TypedIndex[T] => Int): Tensor[T, Int32] =
def fromFunction(f: ElementIndex[T] => Int): Tensor[T, Int32] =
Tensor(shape, VType[Int32]).fromArray(Tensor.tabulate(shape.dimensions, f))
@targetName("fromFunctionLong")
def fromFunction(f: TypedIndex[T] => Long): Tensor[T, Int64] =
def fromFunction(f: ElementIndex[T] => Long): Tensor[T, Int64] =
Tensor(shape, VType[Int64]).fromArray(Tensor.tabulate(shape.dimensions, f))
@targetName("fromFunctionBoolean")
def fromFunction(f: TypedIndex[T] => Boolean): Tensor[T, Bool] =
def fromFunction(f: ElementIndex[T] => Boolean): Tensor[T, Bool] =
Tensor(shape, VType[Bool]).fromArray(Tensor.tabulate(shape.dimensions, f))

/** Factory for creating tensors with a specific shape and a given value type
Expand Down Expand Up @@ -184,10 +184,10 @@ object Tensor:
def fromArray(values: Array[Double])(using IsFloating[V]): Tensor[T, V] = ArrayWriter.fromArray[T, V](other.shape, values)

/** Computes per-element values via eager Scala-side iteration. Used by [[ShapedFactory.fromFunction]]. */
private[tensor] def tabulate[T <: Tuple, V: scala.reflect.ClassTag](dims: List[Int], f: TypedIndex[T] => V): Array[V] =
private[tensor] def tabulate[T <: Tuple, V: scala.reflect.ClassTag](dims: List[Int], f: ElementIndex[T] => V): Array[V] =
val strides = dims.scanRight(1)(_ * _).tail
Array.tabulate(dims.product) { flatIdx =>
f(TypedIndex[T](IndexedSeq.tabulate(dims.length)(d => (flatIdx / strides(d)) % dims(d))))
f(ElementIndex[T](IndexedSeq.tabulate(dims.length)(d => (flatIdx / strides(d)) % dims(d))))
}

private[dimwit] def apply[T <: Tuple: Labels, V](jaxValue: Jax.PyDynamic): Tensor[T, V] = new Tensor(jaxValue)
Expand Down
10 changes: 10 additions & 0 deletions core/src/main/scala/dimwit/tensor/ValueTypeClasses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,13 @@ object ValueTypeClasses:

object IsBoolean:
def apply[V](using ev: IsBoolean[V]): IsBoolean[V] = ev

/** Type class marker for positions along an axis, i.e. `Idx[L]`.
* Deliberately not an `IsNumber`: positions can be compared, but there is no arithmetic on them.
*/
@implicitNotFound("Operation only valid for tensors of positions (Idx[L]).")
trait IsIndex[V] extends HasDType[V]:
def dtype: DType

object IsIndex:
def apply[V](using ev: IsIndex[V]): IsIndex[V] = ev
10 changes: 5 additions & 5 deletions core/src/main/scala/dimwit/tensor/tensorops/AlongAxisOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dimwit.tensor.tensorops

import dimwit.jax.Jax
import dimwit.tensor.Axis
import dimwit.tensor.DType.Int32
import dimwit.tensor.Idx
import dimwit.tensor.Label
import dimwit.tensor.Labels
import dimwit.tensor.ShapeTypeHelpers.AxisIndex
Expand All @@ -24,8 +24,8 @@ private[dimwit] object AlongAxisTensor1Ops:
def sort[L: Label, V: IsNumber](t: Tensor1[L, V]): Tensor1[L, V] =
Tensor(Jax.jnp.sort(t.jaxValue, axis = 0))

/** returns the indices that would sort the Tensor1 `t`. */
def argsort[L: Label, V: IsNumber](t: Tensor1[L, V]): Tensor1[L, Int32] =
/** returns the positions that would sort the Tensor1 `t`, i.e. the permutation of `L` that sorts it. */
def argsort[L: Label, V: IsNumber](t: Tensor1[L, V]): Tensor1[L, Idx[L]] =
Tensor(Jax.jnp.argsort(t.jaxValue, axis = 0))

/** computes the cumulative sum of the Tensor1 `t`. */
Expand Down Expand Up @@ -72,7 +72,7 @@ private[dimwit] object AlongAxisOps:
t.vapply(axis)(AlongAxisTensor1Ops.roll(shift))

/** returns the indices that would sort `t` along the specified axis. */
def argsort[T <: Tuple: Labels, V: IsNumber, L: Label](t: Tensor[T, V], axis: Axis[L])(using AxisIndex[T, L]): Tensor[T, Int32] =
def argsort[T <: Tuple: Labels, V: IsNumber, L: Label](t: Tensor[T, V], axis: Axis[L])(using AxisIndex[T, L]): Tensor[T, Idx[L]] =
t.vapply(axis)(AlongAxisTensor1Ops.argsort)

/** sorts `t` along the specified axis. */
Expand Down Expand Up @@ -123,7 +123,7 @@ private[dimwit] object AlongAxisExtensions:
extension [T <: Tuple: Labels, V: IsNumber](t: Tensor[T, V])

/** Returns a tensor of indices that would sort `t` along the specified axis */
def argsort[L: Label](axis: Axis[L])(using AxisIndex[T, L]): Tensor[T, Int32] =
def argsort[L: Label](axis: Axis[L])(using AxisIndex[T, L]): Tensor[T, Idx[L]] =
AlongAxisOps.argsort(t, axis)

/** sorts the tensor `t` along the specified axis */
Expand Down
13 changes: 7 additions & 6 deletions core/src/main/scala/dimwit/tensor/tensorops/ReductionOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dimwit.tensor.tensorops
import dimwit.jax.Jax
import dimwit.tensor.Axis
import dimwit.tensor.DType.Int32
import dimwit.tensor.Idx
import dimwit.tensor.Label
import dimwit.tensor.Labels
import dimwit.tensor.ShapeTypeHelpers.AxesRemover
Expand Down Expand Up @@ -35,12 +36,12 @@ private[dimwit] object ReductionOps:
def min[T <: Tuple: Labels, V: IsNumber, L: Label](t: Tensor[T, V], axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, V] = Tensor(Jax.jnp.min(t.jaxValue, axis = ev.index))
def min[T <: Tuple: Labels, V: IsNumber, Inputs <: Tuple](t: Tensor[T, V], axes: Inputs)(using ev: AxesRemover[T, UnwrapAxes[Inputs]], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, V] = Tensor(Jax.jnp.min(t.jaxValue, axis = ev.indices.toPythonProxy))

/** returns the index of the maximum of `t` along the specified axis or axes. */
def argmax[T <: Tuple: Labels, V: IsNumber, L: Label](t: Tensor[T, V], axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = Tensor(Jax.jnp.argmax(t.jaxValue, axis = ev.index))
/** returns the position of the maximum of `t` along the specified axis, or the flat index for several axes. */
def argmax[T <: Tuple: Labels, V: IsNumber, L: Label](t: Tensor[T, V], axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Idx[L]] = Tensor(Jax.jnp.argmax(t.jaxValue, axis = ev.index))
def argmax[T <: Tuple: Labels, V: IsNumber, Inputs <: Tuple](t: Tensor[T, V], axes: Inputs)(using ev: AxesRemover[T, UnwrapAxes[Inputs]], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = Tensor(Jax.jnp.argmax(t.jaxValue, axis = ev.indices.toPythonProxy))

/** returns the index of the minimum of `t` along the specified axis or axes. */
def argmin[T <: Tuple: Labels, V: IsNumber, L: Label](t: Tensor[T, V], axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = Tensor(Jax.jnp.argmin(t.jaxValue, axis = ev.index))
/** returns the position of the minimum of `t` along the specified axis, or the flat index for several axes. */
def argmin[T <: Tuple: Labels, V: IsNumber, L: Label](t: Tensor[T, V], axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Idx[L]] = Tensor(Jax.jnp.argmin(t.jaxValue, axis = ev.index))
def argmin[T <: Tuple: Labels, V: IsNumber, Inputs <: Tuple](t: Tensor[T, V], axes: Inputs)(using ev: AxesRemover[T, UnwrapAxes[Inputs]], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = Tensor(Jax.jnp.argmin(t.jaxValue, axis = ev.indices.toPythonProxy))

/** computes the mean of `t` (over all elements, or) along the specified axis or axes. */
Expand Down Expand Up @@ -94,11 +95,11 @@ private[dimwit] object ReductionExtensions:

/** argument of the maximum of the tensor `t` along the specified axes, returning a new tensor with those axes removed. */
def argmax[Inputs <: Tuple](axes: Inputs)(using ev: AxesRemover[T, UnwrapAxes[Inputs]], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = ReductionOps.argmax(t, axes)
def argmax[L: Label](axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = ReductionOps.argmax(t, axis)
def argmax[L: Label](axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Idx[L]] = ReductionOps.argmax(t, axis)

/** argument of the minimum of the tensor `t` along the specified axes, returning a new tensor with those axes removed. */
def argmin[Inputs <: Tuple](axes: Inputs)(using ev: AxesRemover[T, UnwrapAxes[Inputs]], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = ReductionOps.argmin(t, axes)
def argmin[L: Label](axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Int32] = ReductionOps.argmin(t, axis)
def argmin[L: Label](axis: Axis[L])(using ev: AxisRemover[T, L], l: Labels[ev.RemainingAxes]): Tensor[ev.RemainingAxes, Idx[L]] = ReductionOps.argmin(t, axis)

// ---------------------------------------------------------
// IsFloat operations (IsFloat or IsInt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ private[dimwit] object StructuralExtensions:
/** Select the tensor at an index given by a tensor along an axis, removing the axis.
* The index may be traced, e.g. a loop index under `jit`.
*
* @param selector of the form `Axis[L].at(index: Tensor0[Int32])`
* @param selector of the form `Axis[L].at(index: Tensor0[Idx[L]])` or `Axis[L].at(index: Tensor0[Int32])`
*/
def select[L](selector: AxisAtTensorIndex[L])(using
ev: AxisRemover[T, L],
Expand Down Expand Up @@ -579,7 +579,7 @@ private[dimwit] object StructuralExtensions:
/** Select the tensor at the indices of a vector along an axis, like `jnp.take`.
* The axis is replaced by the axis of the indices. Out-of-bounds indices yield NaN for floating tensors.
*
* @param selector of the form `Axis[L].at(indices: Tensor1[L2, Int32])`
* @param selector of the form `Axis[L].at(indices: Tensor1[L2, Idx[L]])`
*/
def select[L, L2](selector: AxisAtTensorIndices[L, L2])(using
ev: AxisReplacer[T, L, L2],
Expand Down Expand Up @@ -638,7 +638,7 @@ private[dimwit] object StructuralExtensions:
/** A copy of the tensor with new values at an index given by a tensor along an axis. The index may be traced.
* An out-of-bounds index leaves the tensor unchanged.
*
* @param selector of the form `Axis[L].at(index: Tensor0[Int32])`
* @param selector of the form `Axis[L].at(index: Tensor0[Idx[L]])` or `Axis[L].at(index: Tensor0[Int32])`
* @param value the new values, with the shape of `tensor.select(selector)`
*/
def updated[L](selector: AxisAtTensorIndex[L])(using
Expand Down Expand Up @@ -688,7 +688,7 @@ private[dimwit] object StructuralExtensions:
/** A copy of the tensor with new values at the indices of a vector along an axis. Out-of-bounds indices are skipped;
* for repeated indices, it is unspecified which of their values is written.
*
* @param selector of the form `Axis[L].at(indices: Tensor1[L2, Int32])`
* @param selector of the form `Axis[L].at(indices: Tensor1[L2, Idx[L]])`
* @param value the new values, with the shape of `tensor.select(selector)`
*/
def updated[L, L2](selector: AxisAtTensorIndices[L, L2])(using
Expand Down
Loading
Loading