- From: Jiewei Qian <notifications@github.com>
- Date: Thu, 21 Jul 2022 22:21:05 -0700
- To: w3ctag/design-reviews <design-reviews@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3ctag/design-reviews/issues/759/1192193552@github.com>
> 1. how does the caller know what kind of format they can .load()? What happens when .load() fails due to an unsupported format? Caller can pass in `modelFormat` when they create context: `ml.createContext({modelFormat: "tflite" }})`. If the backend doesn't support the format, it rejects the promise on `createContext()` and `load()`. > 2. Why is tensor creation a factory and not a constructor? Model Loader shares the same tensor definition with [Neural Network API](https://github.com/webmachinelearning/webnn). Currently, tensor is duck-typed (fixed type array + shape). Discussions on whether tensor should be strongly typed: https://github.com/webmachinelearning/webnn/issues/275 . > 2. Would a tensor be usable in other (non-ML) contexts as well? As a general concept, a tensor is a fixed-size fixed-type arbitrary-dimensional array. Tensor computations are usually expressed using specialized methods (for performance reasons), instead of combining for-loops and basic arithmeric operations. For Model Loader and Neural Network API (and perhaps future ML-related Web API), we aim to share the basic classes (like MLContext and tensor definition). For non-ML context, I'm not sure if Tensor concept is widely used. For non-ML Web API, I'm not sure if Tensor is more advantageous than TypedArray. To get the performance benefit, JavaScript probably needs to express computations using Tensor specific compute methods (instead of doing element-wise computation using loops), this requires further standardizations for each computation type. For example, matrix multiplication, dot product, element-wise add, element-wise multiply need to be 4 methods. -- Reply to this email directly or view it on GitHub: https://github.com/w3ctag/design-reviews/issues/759#issuecomment-1192193552 You are receiving this because you are subscribed to this thread. Message ID: <w3ctag/design-reviews/issues/759/1192193552@github.com>
Received on Friday, 22 July 2022 05:21:18 UTC