Layer

Objective-C

@interface Layer : Algorithm

Swift

class Layer : Algorithm

This interface class allows to build new Layers - are building blocks of networks.

Each class, derived from Layer, must implement allocate() methods to declare own outputs and forward() to compute outputs. Also before using the new layer into networks you must register your layer by using one of REF: dnnLayerFactory “LayerFactory” macros.

Member of Dnn

Methods

  • Returns index of output blob in output array.

    See

    inputNameToIndex()

    Declaration

    Objective-C

    - (int)outputNameToIndex:(nonnull NSString *)outputName;

    Swift

    func outputNameToIndex(outputName: String) -> Int32
  • Computes and sets internal parameters according to inputs, outputs and blobs.

    If this method is called after network has allocated all memory for input and output blobs and before inferencing.

    Declaration

    Objective-C

    - (void)finalize:(nonnull NSArray<Mat *> *)inputs
             outputs:(nonnull NSMutableArray<Mat *> *)outputs;

    Swift

    func finalize(inputs: [Mat], outputs: NSMutableArray)

    Parameters

    outputs

    vector of already allocated output blobs

  • Deprecated

    Allocates layer and computes output. @deprecated This method will be removed in the future release.

    Declaration

    Objective-C

    - (void)run:(nonnull NSArray<Mat *> *)inputs
          outputs:(nonnull NSMutableArray<Mat *> *)outputs
        internals:(nonnull NSMutableArray<Mat *> *)internals;

    Swift

    func run(inputs: [Mat], outputs: NSMutableArray, internals: NSMutableArray)
  • Declaration

    Objective-C

    @property Mat* blobs

    Swift

    var blobs: Mat { get set }
  • Declaration

    Objective-C

    @property (readonly) NSString* name

    Swift

    var name: String { get }
  • Declaration

    Objective-C

    @property (readonly) NSString* type

    Swift

    var type: String { get }
  • Declaration

    Objective-C

    @property (readonly) int preferableTarget

    Swift

    var preferableTarget: Int32 { get }