SerranoResourceManager

public class SerranoResourceManager

This is a framework level class

  • Allocate unmanaged tensors for shapes. Unmanaged means that the alloated tensors will not be hold via strong refrence by manager.

    Declaration

    Swift

    public func allocateUnamangedTensors(_ shapes: [TensorShape]) -> [Tensor]

    Parameters

    shapes

    shapes description

    Return Value

    return value description

  • Allocate unmanaged tensors for shapes. Unmanaged means that the alloated tensors will not be hold via strong refrence by manager.

    Declaration

    Swift

    public func allocateUnamangedTensor(_ shape: TensorShape) -> Tensor

    Parameters

    shapes

    shapes description

    Return Value

    return value description

  • Allocate unamanged MTLBuffers.

    Warning

    If engine has no available GPU device, fatalError raised.

    Declaration

    Swift

    public func allocateUnmanagedMTLBuffers(_ tensors: [Tensor]) -> [MTLBuffer]

    Parameters

    tensors

    target tensors

    Return Value

    Array of MTLBuffer

  • Allocate unamanged MTLBuffer.

    Warning

    If engine has no available GPU device, fatalError raised.

    Declaration

    Swift

    public func allocateUnmanagedMTLBuffe(_ tensor: Tensor) -> MTLBuffer

    Parameters

    tensor

    target tensor

    Return Value

    MTLBuffer

  • Request managed tensors for target shapes.

    Note

    All tensors requested by this method should be return manually by calling returnTensors(_ tensors: [Tensor]) or returnTensor(_ tensor: Tensor)

    Warning

    This method is desgined for framework internal usage. Usually user should not call this method.

    Declaration

    Swift

    public func allocateTensors(_ shapes: [TensorShape]) -> [Tensor]

    Parameters

    shapes

    target shapes

    Return Value

    tensors

  • Allocate single tensor object. This function actually call allocateTensors(forShapes shapes: [TensorShape]).

    Note

    All tensors requested by this method should be return manually by calling returnTensors(_ tensors: [Tensor]) or returnTensor(_ tensor: Tensor)

    Warning

    This method is desgined for framework internal usage. Usually user should not call this method.

    Declaration

    Swift

    public func allocateTensor(_ tensorShape: TensorShape) -> Tensor

    Parameters

    tensorShape

    shape

    Return Value

    tensor

  • Return managed tensors.

    Note

    Tensor not managed by this manager or is a slice tensor will be ignored.

    Declaration

    Swift

    public func returnTensors(_ tensors: [Tensor])

    Parameters

    tensors

    returned tensors

  • Return single tensor to resource manager

    Declaration

    Swift

    public func returnTensor(_ tensor: Tensor)

    Parameters

    tensor

    tensor

  • Release target tensors. Actually clear corresponding entries in tensorStatusTable and tensorBufferTable.

    Note

    Tensor not managed by this manager or is a slice tensor will be ignored.

    Declaration

    Swift

    public func releaseTensors(_ tensors: [Tensor])

    Parameters

    tensors

    target tensors

  • Check if a managed tensor is availabel for reuse If the passed in tensor is a sliced tensor, we check the status of its root tensor.

    Note

    false will be returned if tensor is not managed by this manager.

    Declaration

    Swift

    public func isTensorAvailable(_ tensor: Tensor) -> Bool
  • Release all managed resources

    Warning

    This function does not guranteen that all managed tensors and buffers would be released in memory, since if tensor or buffer objects are still used in other places, the ARC will nor clear it. Before calling this function, the caller must be clear that all managed resources are in idle states.

    Declaration

    Swift

    public func releaseAllResources()
  • Check if tensor is managed by this manager. If a tensor is managed by this manager, all its sliced tensors are managed by this manager.

    Note

    If the tensor is a sliced tensor, we will check if managing its root tensor.

    Declaration

    Swift

    public func isManagingTensor(_ tensor: Tensor) -> Bool

    Parameters

    tensor

    tensor description

    Return Value

    return value description

  • Check if a MTLBuffer is managed by this manager

    Declaration

    Swift

    public func isManagingBufferr(_ buffer: MTLBuffer) -> Bool

    Parameters

    buffer

    buffer description

    Return Value

    return value description