Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator naming 2D vs 2d #821

Open
fdwr opened this issue Feb 21, 2025 · 1 comment
Open

Operator naming 2D vs 2d #821

fdwr opened this issue Feb 21, 2025 · 1 comment

Comments

@fdwr
Copy link
Collaborator

fdwr commented Feb 21, 2025

From comment #805 (comment), the API naming is internally inconsistent:

  • resample2d, conv2d, scatterND - current
  • resample2d, conv2d, scatterNd - rename scatterNd to be consistent with precedent
  • resample2D, conv2D, scatterND - rename existing functions to uppercase D

The initial TAG review had no casing feedback, and the guidance here https://w3ctag.github.io/design-principles/#casing-rules isn't so clear. Thanks @anssiko.

Precedent

WebGPU

Looking at WebGPU (the closest aligned existing W3C spec), we see lowercase d in enum strings and uppercase D in class/field identifiers. I didn't see any function names, but presumably they would be more consistent with field names than enum strings.

class names:

CanvasRenderingContext2D
GPUOrigin2D
GPUOrigin2DDict
GPUExtent3D 
GPUOrigin3D
GPUOrigin3DDict

field names:

maxTextureDimension1D
maxTextureDimension2D
maxTextureDimension3D

enums:

enum GPUTextureDimension {
    "1d",
    "2d",
    "3d",
};

enum GPUTextureViewDimension {
    "1d",
    "2d",
    "2d-array",
    "cube",
    "cube-array",
    "3d",
};

Other external guides

I see conflicting recommendations out there.

Favoring Nd:

https://google.github.io/styleguide/tsguide.html#descriptive-names

Treat abbreviations like acronyms in names as whole words, i.e. use loadHttpUrl, not loadHTTPURL, unless required by a platform name (e.g. XMLHttpRequest).

// Good identifiers:
dnsConnectionIndex // Most people know what "DNS" stands for.
referrerUrl // Ditto for "URL".
customerId // "Id" is both ubiquitous and unlikely to be misunderstood.

// Disallowed identifiers:
...
customerID // Incorrect camelcase of "ID".

Favoring ND:

https://github.com/airbnb/javascript?tab=readme-ov-file#naming--Acronyms-and-Initialisms

// bad
import SmsContainer from './containers/SmsContainer';
const HttpRequests = [ ... ];

// good
import SMSContainer from './containers/SMSContainer';
const HTTPRequests = [ ... ];

Future considerations

This might be mostly a moot point upon extending conv2d/convTranspose2d/resample2d/averagePool2d/l2Pool2d/maxPool2d to be more generic than just 2 dimensions, but it still applies to ScatterNd/ND.

@inexorabletash
Copy link
Member

For method names, WebGL has:

  • texStorage2D()
  • texImage2D()
  • texSubImage2D()
  • compressedTexImage2D()
  • compressedTexSubImage2D()

There's also a prototype implementation in Chromium of "Mesh2D" that has:

  • createMesh2DVertexBuffer()
  • createMesh2DUVBuffer()
  • createMesh2DIndexBuffer()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants