webmachinelearning / webnn

🧠 Web Neural Network API
https://www.w3.org/TR/webnn/
Other
398 stars 48 forks source link

Rename inputSize variables as inputRank in algorithms #588

Closed inexorabletash closed 8 months ago

inexorabletash commented 9 months ago

Per discussion in https://github.com/webmachinelearning/webnn/pull/582#discussion_r1503644898 @fdwr writes:

inputSize is quite ambiguous alone because many ML libraries have a Size() operator which (for better or worse, and probably should have been called ElementCount() instead) returns the total number of elements, not the count of dimensions. So, inputRank or inputShapeSize or inputDimensionCount would all be clearer names (with inputRank being the most concise)

So any place where "size" is being used to refer to the number of dimensions, replace with "rank".

Note though that while an MLOperand has a rank, if what an algorithm is processing is a list that list has a size not a rank. If the list is a list of dimensions, it's fine to store that in a local variable called rank, though!

inexorabletash commented 9 months ago

FYI I'll put up a PR for this once the queue is smaller.