WebAssembly / wasi-nn

Neural Network proposal for WASI
470 stars 36 forks source link

Use names instead of numbers to identify inputs and outputs #48

Closed abrown closed 1 year ago

abrown commented 1 year ago

I've heard this feedback from several people recently and wanted to open this up for discussion: many ML frameworks now use names (i.e., strings) instead of numeric indexes for identifying inputs and outputs. Currently set-input and get-output both use numeric indexes. Should we switch the API to use names instead?

The current API would replace set-input and get-output with:

set-input: func(ctx: graph-execution-context, name: string, tensor: tensor) -> result<_, error>
get-output: func(ctx: graph-execution-context, name: string) -> result<tensor-data, error>

If #43 is adopted, which removes graph-execution-context, then the compute call would change to:

type tensor-map = list<tuple<string, tensor>>
compute: func(inputs: tensor-map) -> result<tensor-map, error>
geekbeast commented 1 year ago

This seems like a no brainer. Using indexes seems pretty brittle as it is decoupled from the semantic meaning of the value and makes for less clear code (i.e poor developer experience for users of the api)