Save the date! Google I/O returns May 18-20 Register now


public struct TensorHandle<Scalar> where Scalar : _TensorFlowDataTypeCompatible
extension TensorHandle: TensorGroup

TensorHandle is the type used by ops. It includes a Scalar type, which compiler internals can use to determine the datatypes of parameters when they are extracted into a tensor program.

  • Declaration

    public init(_owning cTensorHandle: CTensorHandle)
  • Declaration

    public init(handle: _AnyTensorHandle)
  • Declaration

    public init(_owning tensorHandles: UnsafePointer<CTensorHandle>?)
  • Declaration

    public init<C: RandomAccessCollection>(
      _handles: C
    ) where C.Element: _AnyTensorHandle
  • The number of dimensions of the Tensor.


    public var rank: Int { get }
  • The shape of the Tensor.


    public var shape: TensorShape { get }
  • The backend used to dispatch ops.


    public var backend: Device.Backend { get }
  • Create a ShapedArray with contents of the underlying TensorHandle. If the TensorHandle is on the accelerator, it will be copied to the host.


    func makeHostCopy() -> ShapedArray<Scalar>

    Return Value

    A ShapedArray.

  • Create a TensorHandle with a closure that initializes the underlying buffer.

    scalarsInitializer receives a buffer with exactly enough capacity to hold the scalars in a tensor with shape shape. scalarsInitializer must initialize the entire buffer, with contiguous scalars in row-major order.


    public init(
      shape: [Int],
      scalarsInitializer: (UnsafeMutablePointer<Scalar>) -> Void