TIOLayerInterface

@interface TIOLayerInterface : NSObject

Encapsulates information about the input and output layers of a model, fully described by a TIOLayerDescription. Used internally by a model when parsing its description. Also used to match inputs and outputs to their corresponding layers.

This is an algebraic data type inspired by Remodel: https://github.com/facebook/remodel. In Swift it would be an Enumeration with Associated Values. The intent is to capture the variety of inputs and outputs a model can accept and produce in a unified interface.

Normally you will not need to interact with this class, although you may request a TIOLayerDescription from a conforming TIOModel for inputs or outputs that you are specifically interested in, for example, a pixel buffer input when you want greater control over scaling and clipping an image before passing it to the model.

  • Initializes a TIOLayerInterface with a pixel buffer description.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithName:(nonnull NSString *)name
                                 isInput:(BOOL)isInput
                  pixelBufferDescription:(nonnull TIOPixelBufferLayerDescription *)
                                             pixelBufferDescription;

    Swift

    init(name: String, isInput: Bool, pixelBufferDescription: TIOPixelBufferLayerDescription)

    Parameters

    pixelBufferDescription

    Description of the expected pixel buffer

    Return Value

    TIOLayerInterface The encapsulated description

  • Initializes a TIOLayerInterface with a vector description, e.g. the description of a vector, matrix, or other tensor.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithName:(nonnull NSString *)name
                                 isInput:(BOOL)isInput
                       vectorDescription:
                           (nonnull TIOVectorLayerDescription *)vectorDescription;

    Swift

    init(name: String, isInput: Bool, vectorDescription: TIOVectorLayerDescription)

    Parameters

    vectorDescription

    Description of the expected vector

    Return Value

    TIOLayerInterface The encapsulated description

  • Unavailable

    Use one of the above initializers

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • The name of the model interface

    May corresponding to an actual layer name or be your own name. The name will be used to copy values to a tensor buffer when a model is run on an NSDictionary input or to associate an output with a given name.

    Declaration

    Objective-C

    @property (readonly, atomic) NSString *_Nonnull name;

    Swift

    var name: String { get }
  • YES if this describes an input to the model, NO if this describes an output to the model.

    Declaration

    Objective-C

    @property (readonly, getter=isInput, atomic) BOOL input;

    Swift

    var isInput: Bool { get }
  • The underlying data description.

    Generally you should use the match-case function instead of accessing the underlying TIOLayerDescription directly.

    Declaration

    Objective-C

    @property (readonly, atomic) id<TIOLayerDescription> _Nonnull dataDescription;

    Swift

    var dataDescription: TIOLayerDescription { get }
  • Use this function to switch on the underlying description.

    When preparing inputs and capturing outputs, a TIOModel uses the underlying description of a layer in order to determine how to move bytes around.

    Declaration

    Objective-C

    - (void)matchCasePixelBuffer:(nonnull TIOPixelBufferMatcher)pixelBufferMatcher
                      caseVector:(nonnull TIOVectorMatcher)vectorMatcher;

    Swift

    func matchCasePixelBuffer(_ pixelBufferMatcher: @escaping TIOPixelBufferMatcher, caseVector vectorMatcher: @escaping TIOVectorMatcher)