Skip to content

feat: add methods to fetch a dimension index & size according to its data format

Context

This is an implementation for issue aidge#315.

It adds the following methods:

  • For each dimension, a method to get its index according to a DataFormat
getBatchIdx(DataFormat::NC);   // Returns 0
getDepthIdx(DataFormat::NC);   // Returns 255 - A tombstone value indicating an unsupported dimension
getChannelIdx(DataFormat::NC); // Returns 1
  • Given a tensor and for each dimension, a method to get its index according to its DataFormat.
tensor.setDataFormat(DataFormat::NC);
tensor.getBatchIdx();   // It returns 0
tensor.getDepthIdx();   // It returns 255
tensor.getChannelIdx(); // It returns 1

[!note]

  • If format is defined, then it uses getBatchIdx(tensor.mDataFormat),
  • If format is undefined (Default or Any), it assumes a format according to its dimension's size.
  • Given a tensor and for each dimension, a method to get its size according to its DataFormat
Tensor tensor = Tensor({12, 22});
tensor.setDataFormat(DataFormat::NC);
tensor.getBatch();   // It returns 12
tensor.getDepth();   // It returns 1 (default for each unsupported dimensions)
tensor.getChannel(); // It returns 22

Detailed major modifications

  • Change the X-Macro signature used in those files
  • Change DataFormat type to short from int
  • Added corresponding methods to DataFormat.hpp and Tensor.hpp
  • All methods are tested.
  • Python bindings node_export.py were also updated to use these functions.

Status

  • NOT DONE
  • DONE
  • TO DO
  • IN PROGRESS
Edited by Tristan de Blauwe

Merge request reports

Loading