Structures

The following structures are available globally.

  • The tensor shape description. Specify the shape and data type of a Tensor data object.

    ## dataType Indicate the initial set data type.

    ## shapeArray The shape attrribute defines the dimension of a Tensor object. In serrano, we follow row-marjor order to store and access elements in a Tensor object and each row is represented as an array. For a given shape array with n indices [i_0, i_1, ..., i_(n-1)], each index from i_0 to i_(n-2) defines the number of rows in its previous dimension. The last index define the number of elements in its previous dimention. For example, a TensorShape object with shpae as [2, 1, 3]. It’s 1st dimension has 2 rows in which each row has 1 row with 3 elements.

    User should be clear and unserstanding what a Tensor object looks like when they passing in a TensorShape argument. For example, a Tensor object with shape [2, 3], it can be visulized as a nested array like below:

         // shape [2, 3]
         [
            [1.0, 0.5, 1.3],
            [2.0, 4.2, 6.7],
         ]
    

    And a typical real-world example, a 3-channel RGB image data could be represented with shape [3, image_hight, image_width]:

         [
            // R channel frame
            [
                [232, ..., 123], // (# of Int elements) = image_width
                .
                .
                .
                [113, ..., 225]
            ], // (# of Array elements) = image_hight
    
            // G channel frame
            [
                [232, ..., 123],
                .
                .
                .
                [113, ..., 225]
            ],
    
            // B channel frame
            [
                [232, ..., 123],
                .
                .
                .
                [113, ..., 225]
            ]
        ]
    

    Equatable

    Two TensorShape objects are equal (==)if they have the same shape.

    Two TensorShape objects are dot equal (.==) if they have the same shape and same dataType.

    Rank is 0

    If a Tensor object’s shapeArray has 0 rank, it indicates that it just contains a scalar value.

    See more

    Declaration

    Swift

    public struct TensorShape: Equatable, Comparable