Contents

withMLTensorComputePolicy(_:_:)

Calls the given closure within a task-local context using the specified compute policy to influence what compute device tensor operations are executed on.

Declaration

func withMLTensorComputePolicy<R>(_ computePolicy: MLComputePolicy, _ body: () async throws -> R) async rethrows -> R

Parameters

  • computePolicy:

    A compute policy that will be set before the closure gets called and restored after the closure returns.

  • body:

    A nullary closure. If the closure has a return value, that value is also used as the return value of the withMLTensorComputePolicy(_:_:) function.

Return Value

The return value, if any, of the body closure.

See Also

Model tensor