Skip to content

Remove the support of negative dimension values #279

@huningxin

Description

@huningxin

The existing spec allows to use negative value to define unknown dimension in an MLOperandDescriptor as

dictionary MLOperandDescriptor {
  // The operand type.
  required MLOperandType type;

  // The dimensions field is only required for tensor operands.
  // The negative value means an unknown dimension.
  sequence<long> dimensions;
};

However, according to the investigation of native ML APIs used by WebNN-native implementation, this feature is not supported widely. The following table captures some examples for reference:

native API data type of dimension value
XNNPACK size_t
DirectML UINT
NNAPI uint32_t
MLAS size_t
OpenVINO size_t
BNNS size_t
MPS NSUInteger

Given that, I'd like to propose to remove the support of negative dimension values and use unsigned long data type instead.

/cc @yuhonglin, thanks for raising this issue when reviewing a Chromium WebNN CL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions