Data Structures & Feature Types

StringToInt64Map

A mapping from a string to a 64-bit integer.

message StringToInt64Map {
    map<string, int64> map = 1;
}

StringToInt64Map.MapEntry

// Copyright (c) 2017, Apple Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-3-clause license that can be
// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause

syntax = "proto3";
option optimize_for = LITE_RUNTIME;

import public "FeatureTypes.proto";

package CoreML.Specification;

message StringToInt64Map {
    map<string, int64> map = 1;
}

message Int64ToStringMap {
    map<int64, string> map = 1;
}

message StringToDoubleMap {
    map<string, double> map = 1;
}

message Int64ToDoubleMap {
    map<int64, double> map = 1;
}

message StringVector {
    repeated string vector = 1;
}

message Int64Vector {
    repeated int64 vector = 1;
}

message DoubleVector {
    repeated double vector = 1;
}

Int64ToStringMap

A mapping from a 64-bit integer to a string.

message Int64ToStringMap {
    map<int64, string> map = 1;
}

Int64ToStringMap.MapEntry

// Copyright (c) 2017, Apple Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-3-clause license that can be
// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause

syntax = "proto3";
option optimize_for = LITE_RUNTIME;

import public "FeatureTypes.proto";

package CoreML.Specification;

message StringToInt64Map {
    map<string, int64> map = 1;
}

message Int64ToStringMap {
    map<int64, string> map = 1;
}

message StringToDoubleMap {
    map<string, double> map = 1;
}

message Int64ToDoubleMap {
    map<int64, double> map = 1;
}

message StringVector {
    repeated string vector = 1;
}

message Int64Vector {
    repeated int64 vector = 1;
}

message DoubleVector {
    repeated double vector = 1;
}

StringToDoubleMap

A mapping from a string to a double-precision floating point number.

message StringToDoubleMap {
    map<string, double> map = 1;
}

StringToDoubleMap.MapEntry

// Copyright (c) 2017, Apple Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-3-clause license that can be
// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause

syntax = "proto3";
option optimize_for = LITE_RUNTIME;

import public "FeatureTypes.proto";

package CoreML.Specification;

message StringToInt64Map {
    map<string, int64> map = 1;
}

message Int64ToStringMap {
    map<int64, string> map = 1;
}

message StringToDoubleMap {
    map<string, double> map = 1;
}

message Int64ToDoubleMap {
    map<int64, double> map = 1;
}

message StringVector {
    repeated string vector = 1;
}

message Int64Vector {
    repeated int64 vector = 1;
}

message DoubleVector {
    repeated double vector = 1;
}

Int64ToDoubleMap

A mapping from a 64-bit integer to a double-precision floating point number.

message Int64ToDoubleMap {
    map<int64, double> map = 1;
}

Int64ToDoubleMap.MapEntry

// Copyright (c) 2017, Apple Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-3-clause license that can be
// found in LICENSE.txt or at https://opensource.org/licenses/BSD-3-Clause

syntax = "proto3";
option optimize_for = LITE_RUNTIME;

import public "FeatureTypes.proto";

package CoreML.Specification;

message StringToInt64Map {
    map<string, int64> map = 1;
}

message Int64ToStringMap {
    map<int64, string> map = 1;
}

message StringToDoubleMap {
    map<string, double> map = 1;
}

message Int64ToDoubleMap {
    map<int64, double> map = 1;
}

message StringVector {
    repeated string vector = 1;
}

message Int64Vector {
    repeated int64 vector = 1;
}

message DoubleVector {
    repeated double vector = 1;
}

StringVector

A vector of strings.

message StringVector {
    repeated string vector = 1;
}

Int64Vector

A vector of 64-bit integers.

message Int64Vector {
    repeated int64 vector = 1;
}

DoubleVector

A vector of double-precision floating point numbers.

message DoubleVector {
    repeated double vector = 1;
}

Int64FeatureType

The 64-bit integer feature type.

message Int64FeatureType {}

DoubleFeatureType

The double-precision floating point number feature type.

message DoubleFeatureType {}

StringFeatureType

The string feature type.

message StringFeatureType {}

SizeRange

message SizeRange {
    uint64 lowerBound = 1;
    int64 upperBound = 2; // negative value means unbound otherwise upperbound is included in range
}

ImageFeatureType

The image feature type.

message ImageFeatureType {
    // Assumes raw (decompressed) format
    enum ColorSpace {
        INVALID_COLOR_SPACE = 0;
        GRAYSCALE = 10; //  8 bits per pixel
        RGB = 20;       // 32 bits per pixel: RGBA with A channel ignored
        BGR = 30;       // 32 bits per pixel: BGRA with A channel ignored
    }

    message ImageSize {
        uint64 width = 1;
        uint64 height = 2;
    }

    message EnumeratedImageSizes {
        repeated ImageSize sizes = 1;
    }

    message ImageSizeRange {
        SizeRange widthRange = 1;
        SizeRange heightRange = 2;
    }

    // The required or default image size is width x height
    //
    // If specificationVersion <= 2 or SizeFlexibility is empty,
    // width x height is the required fixed image size
    //
    // If SizeFlexibility is present, width x height indicate a "default"
    // image size which must be consistent with the flexibilty specified

    int64 width = 1;
    int64 height = 2;

    // For specification version >= 3 you can specify image size flexibility.

    oneof SizeFlexibility {

        // Use enumeratedSizes for a set of distinct fixed sizes
        // e.g. portrait or landscape: [80 x 100, 100 x 8]
        //
        // If the width x height fields above are specified then they must be
        // one of the sizes listed.
        //
        // If width and height are not specified above then the default width
        // and height will be enumeratedSizes[0]
        //
        // Must be non-empty

        EnumeratedImageSizes enumeratedSizes = 21;

        // Use imageSizeRange to allow for ranges of values
        // e.g. any image greater than 10 x 20: [10..<max] x [20..<max]
        //
        // If width and height are specified above they must fall in the range
        // specified in imageSizeRange. They will be treated as the default size.
        //
        // If width and height are not specified above then the default width
        // and height will be imageSizeRange.widthRange.lowerBound x imageSizeRange.heightRange.lowerBound

        ImageSizeRange imageSizeRange = 31;
    }

    ColorSpace colorSpace = 3;
}

ImageFeatureType.ImageSize

message ImageSize {
    uint64 width = 1;
    uint64 height = 2;
}

ImageFeatureType.EnumeratedImageSizes

message EnumeratedImageSizes {
    repeated ImageSize sizes = 1;
}

ImageFeatureType.ImageSizeRange

message ImageSizeRange {
    SizeRange widthRange = 1;
    SizeRange heightRange = 2;
}

ArrayFeatureType

The array feature type.

message ArrayFeatureType {

enum ArrayDataType {
        INVALID_ARRAY_DATA_TYPE = 0;
        FLOAT32 = 65568; // 0x10000 | 32
        DOUBLE = 65600;  // 0x10000 | 64
        INT32 = 131104;  // 0x20000 | 32
    }

    // The required or default shape
    //
    // If specificationVersion <= 2 or ShapeFlexibility is empty,
    // shape is the required fixed shape
    //
    // If ShapeFlexibility is present, shape indicate a "default"
    // shape which must be consistent with the flexibilty specified
    //
    // For neural networks, shape must be of length 1 or 3, representing input shape [C] or [C,H,W], respectively.
    repeated int64 shape = 1;

    ArrayDataType dataType = 2;

    message Shape {
        repeated int64 shape = 1;
    }

    message EnumeratedShapes {
        repeated Shape shapes = 1;
    }

    message ShapeRange {
        // sizeRanges.size() must be length 1 or 3
        // sizeRanges[d] specifies the allowed range for dimension d
        repeated SizeRange sizeRanges = 1;
    }

    // For specification version >= 3 you can specify image size flexibility.

    oneof ShapeFlexibility {

        // Use enumeratedShapes for a set of distinct fixed shapes
        //
        // If the shape field is specified then it must be
        // one of the enumerated shapes.
        // If shape is not specifed, the "default" shape will be considered
        // enumeratedShapes[0]
        //
        // Must be non-empty

        EnumeratedShapes enumeratedShapes = 21;

        // Use shapeRange to allow the size of each dimension vary within
        // indpendently specified ranges
        //
        // If you specify shape above it must fall in the range
        // specified in shapeRanges. It will be treated as the default shape.
        //
        // If you don't specify shape above then the default shape will
        // have shape[d] = shapeRange.sizeRanges[d].lowerBound

        ShapeRange shapeRange = 31;

    }
}

ArrayFeatureType.Shape

message Shape {
    repeated int64 shape = 1;
}

ArrayFeatureType.EnumeratedShapes

message EnumeratedShapes {
    repeated Shape shapes = 1;
}

ArrayFeatureType.ShapeRange

message ShapeRange {
    // sizeRanges.size() must be length 1 or 3
    // sizeRanges[d] specifies the allowed range for dimension d
    repeated SizeRange sizeRanges = 1;
}

DictionaryFeatureType

The dictionary feature type.

message DictionaryFeatureType {
    oneof KeyType {
        Int64FeatureType int64KeyType = 1;
        StringFeatureType stringKeyType = 2;
    }
}

SequenceFeatureType

The Sequence feature type.

message SequenceFeatureType {

    oneof Type {
        Int64FeatureType int64Type = 1;
        StringFeatureType stringType = 3;
    }

    // Range of allowed size/length/count of sequence
    SizeRange sizeRange = 101;
}

FeatureType

A feature, which may be optional.

message FeatureType {
    oneof Type {
        Int64FeatureType int64Type = 1;
        DoubleFeatureType doubleType = 2;
        StringFeatureType stringType = 3;
        ImageFeatureType imageType = 4;
        ArrayFeatureType multiArrayType = 5;
        DictionaryFeatureType dictionaryType = 6;
        SequenceFeatureType sequenceType = 7;
    }

    bool isOptional = 1000;
}

ArrayFeatureType.ArrayDataType

enum ArrayDataType {
        INVALID_ARRAY_DATA_TYPE = 0;
        FLOAT32 = 65568; // 0x10000 | 32
        DOUBLE = 65600;  // 0x10000 | 64
        INT32 = 131104;  // 0x20000 | 32
    }

ImageFeatureType.ColorSpace

enum ColorSpace {
    INVALID_COLOR_SPACE = 0;
    GRAYSCALE = 10; //  8 bits per pixel
    RGB = 20;       // 32 bits per pixel: RGBA with A channel ignored
    BGR = 30;       // 32 bits per pixel: BGRA with A channel ignored
}