Skip to main content
Log in

Mojo function

elementwise

elementwise[func: fn[Int, Int](StaticIntTuple[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = 0, target: StringLiteral = "cpu"](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](StaticIntTuple[$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 (StringLiteral): The target to run on.

Args:

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

elementwise[rank: Int, //, func: fn[Int, Int](StaticIntTuple[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = 0, target: StringLiteral = "cpu"](shape: StaticIntTuple[rank])

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](StaticIntTuple[$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 (StringLiteral): The target to run on.

Args:

  • ​shape (StaticIntTuple[rank]): The shape of the buffer.

elementwise[func: fn[Int, Int](StaticIntTuple[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = 0, target: StringLiteral = "cpu"](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](StaticIntTuple[$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 (StringLiteral): The target to run on.

Args:

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

elementwise[rank: Int, //, func: fn[Int, Int](StaticIntTuple[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = 0, target: StringLiteral = "cpu"](shape: StaticIntTuple[rank], 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](StaticIntTuple[$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 (StringLiteral): The target to run on.

Args:

  • ​shape (StaticIntTuple[rank]): The shape of the buffer.
  • ​context (DeviceContext): The device context to use.

elementwise[rank: Int, //, func: fn[Int, Int](StaticIntTuple[$1]) capturing -> None, simd_width: Int, *, use_blocking_impl: Bool = 0, target: StringLiteral = "cpu"](shape: StaticIntTuple[rank], context: MojoCallContextPtr)

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](StaticIntTuple[$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 (StringLiteral): The target to run on.

Args:

  • ​shape (StaticIntTuple[rank]): The shape of the buffer.
  • ​context (MojoCallContextPtr): The device context to use.

Was this page helpful?