Skip to main content
Log in

Mojo function

elementwise

elementwise[: origin.set, //, func: fn[Int, Int](Index[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = False, target: StringSlice[StaticConstantOrigin] = StringSlice("cpu"), _trace_description: StringSlice[StaticConstantOrigin] = StringSlice("")](shape: Int)

Executes func[width, rank](indices), possibly as sub-tasks, for a suitable combination of width and indices so as to cover shape. Returns when all sub-tasks have completed.

Parameters:

  • func (fn[Int, Int](Index[$1]) capturing -> None): The body function.
  • simd_width (Int): The SIMD vector width to use.
  • use_blocking_impl (Bool): Do not invoke the function using asychronous calls.
  • target (StringSlice[StaticConstantOrigin]): The target to run on.
  • _trace_description (StringSlice[StaticConstantOrigin]): Description of the trace.

Args:

  • shape (Int): The shape of the buffer.

elementwise[: origin.set, rank: Int, //, func: fn[Int, Int](Index[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = False, target: StringSlice[StaticConstantOrigin] = StringSlice("cpu"), _trace_description: StringSlice[StaticConstantOrigin] = StringSlice("")](shape: Index[rank, element_bitwidth=element_bitwidth, unsigned=unsigned])

Executes func[width, rank](indices), possibly as sub-tasks, for a suitable combination of width and indices so as to cover shape. Returns when all sub-tasks have completed.

Parameters:

  • rank (Int): The rank of the buffer.
  • func (fn[Int, Int](Index[$1]) capturing -> None): The body function.
  • simd_width (Int): The SIMD vector width to use.
  • use_blocking_impl (Bool): Do not invoke the function using asychronous calls.
  • target (StringSlice[StaticConstantOrigin]): The target to run on.
  • _trace_description (StringSlice[StaticConstantOrigin]): Description of the trace.

Args:

  • shape (Index[rank, element_bitwidth=element_bitwidth, unsigned=unsigned]): The shape of the buffer.

elementwise[: origin.set, //, func: fn[Int, Int](Index[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = False, target: StringSlice[StaticConstantOrigin] = StringSlice("cpu"), _trace_description: StringSlice[StaticConstantOrigin] = StringSlice("")](shape: Int, context: DeviceContext)

Executes func[width, rank](indices), possibly as sub-tasks, for a suitable combination of width and indices so as to cover shape. Returns when all sub-tasks have completed.

Parameters:

  • func (fn[Int, Int](Index[$1]) capturing -> None): The body function.
  • simd_width (Int): The SIMD vector width to use.
  • use_blocking_impl (Bool): Do not invoke the function using asychronous calls.
  • target (StringSlice[StaticConstantOrigin]): The target to run on.
  • _trace_description (StringSlice[StaticConstantOrigin]): Description of the trace.

Args:

  • shape (Int): The shape of the buffer.
  • context (DeviceContext): The device context to use.

elementwise[: origin.set, rank: Int, //, func: fn[Int, Int](Index[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = False, target: StringSlice[StaticConstantOrigin] = StringSlice("cpu"), _trace_description: StringSlice[StaticConstantOrigin] = StringSlice("")](shape: Index[rank, element_bitwidth=element_bitwidth, unsigned=unsigned], context: DeviceContext)

Executes func[width, rank](indices), possibly as sub-tasks, for a suitable combination of width and indices so as to cover shape. Returns when all sub-tasks have completed.

Parameters:

  • rank (Int): The rank of the buffer.
  • func (fn[Int, Int](Index[$1]) capturing -> None): The body function.
  • simd_width (Int): The SIMD vector width to use.
  • use_blocking_impl (Bool): Do not invoke the function using asychronous calls.
  • target (StringSlice[StaticConstantOrigin]): The target to run on.
  • _trace_description (StringSlice[StaticConstantOrigin]): Description of the trace.

Args:

  • shape (Index[rank, element_bitwidth=element_bitwidth, unsigned=unsigned]): The shape of the buffer.
  • context (DeviceContext): The device context to use.

elementwise[: origin.set, rank: Int, //, func: fn[Int, Int](Index[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = False, target: StringSlice[StaticConstantOrigin] = StringSlice("cpu"), _trace_description: StringSlice[StaticConstantOrigin] = StringSlice("")](shape: Index[rank, element_bitwidth=element_bitwidth, unsigned=unsigned], context: DeviceContextPtr)

Executes func[width, rank](indices), possibly as sub-tasks, for a suitable combination of width and indices so as to cover shape. Returns when all sub-tasks have completed.

Parameters:

  • rank (Int): The rank of the buffer.
  • func (fn[Int, Int](Index[$1]) capturing -> None): The body function.
  • simd_width (Int): The SIMD vector width to use.
  • use_blocking_impl (Bool): Do not invoke the function using asychronous calls.
  • target (StringSlice[StaticConstantOrigin]): The target to run on.
  • _trace_description (StringSlice[StaticConstantOrigin]): Description of the trace.

Args:

  • shape (Index[rank, element_bitwidth=element_bitwidth, unsigned=unsigned]): The shape of the buffer.
  • context (DeviceContextPtr): The device context to use.