Have a question? Connect with the community at the TensorFlow Forum Visit Forum

TensorHandle

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.

    Declaration

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

    Declaration

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

    Declaration

    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.

    Declaration

    @inline(never)
    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.

    Declaration

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