|
| 1 | +partial interface Navigator { |
| 2 | + readonly attribute ML ml; |
| 3 | +}; |
| 4 | + |
| 5 | +interface ML { |
| 6 | + NeuralNetworkContext getNeuralNetworkContext(); |
| 7 | +}; |
| 8 | + |
| 9 | +interface NeuralNetworkContext { |
| 10 | + // Operand types. |
| 11 | + const long FLOAT32 = 0; |
| 12 | + const long INT32 = 1; |
| 13 | + const long UINT32 = 2; |
| 14 | + const long TENSOR_FLOAT32 = 3; |
| 15 | + const long TENSOR_INT32 = 4; |
| 16 | + const long TENSOR_QUANT8_ASYMM = 5; |
| 17 | + |
| 18 | + // Operation types. |
| 19 | + const long ADD = 0; |
| 20 | + const long AVERAGE_POOL_2D = 1; |
| 21 | + const long CONCATENATION = 2; |
| 22 | + const long CONV_2D = 3; |
| 23 | + const long DEPTHWISE_CONV_2D = 4; |
| 24 | + const long DEPTH_TO_SPACE = 5; |
| 25 | + const long DEQUANTIZE = 6; |
| 26 | + const long EMBEDDING_LOOKUP = 7; |
| 27 | + const long FLOOR = 8; |
| 28 | + const long FULLY_CONNECTED = 9; |
| 29 | + const long HASHTABLE_LOOKUP = 10; |
| 30 | + const long L2_NORMALIZATION = 11; |
| 31 | + const long L2_POOL_2D = 12; |
| 32 | + const long LOCAL_RESPONSE_NORMALIZATION = 13; |
| 33 | + const long LOGISTIC = 14; |
| 34 | + const long LSH_PROJECTION = 15; |
| 35 | + const long LSTM = 16; |
| 36 | + const long MAX_POOL_2D = 17; |
| 37 | + const long MUL = 18; |
| 38 | + const long RELU = 19; |
| 39 | + const long RELU1 = 20; |
| 40 | + const long RELU6 = 21; |
| 41 | + const long RESHAPE = 22; |
| 42 | + const long RESIZE_BILINEAR = 23; |
| 43 | + const long RNN = 24; |
| 44 | + const long SOFTMAX = 25; |
| 45 | + const long SPACE_TO_DEPTH = 26; |
| 46 | + const long SVDF = 27; |
| 47 | + const long TANH = 28; |
| 48 | + |
| 49 | + // Fused activation function types. |
| 50 | + const long FUSED_NONE = 0; |
| 51 | + const long FUSED_RELU = 1; |
| 52 | + const long FUSED_RELU1 = 2; |
| 53 | + const long FUSED_RELU6 = 3; |
| 54 | + |
| 55 | + // Implicit padding algorithms. |
| 56 | + const long PADDING_SAME = 1; |
| 57 | + const long PADDING_VALID = 2; |
| 58 | + |
| 59 | + // Execution preferences. |
| 60 | + const long PREFER_LOW_POWER = 0; |
| 61 | + const long PREFER_FAST_SINGLE_ANSWER = 1; |
| 62 | + const long PREFER_SUSTAINED_SPEED = 2; |
| 63 | + |
| 64 | + Promise<Model> createModel(); |
| 65 | +}; |
| 66 | + |
| 67 | +dictionary OperandOptions { |
| 68 | + required long type; |
| 69 | + sequence<unsigned long> dimensions; |
| 70 | + float scale; |
| 71 | + long zeroPoint; |
| 72 | +}; |
| 73 | + |
| 74 | +interface Model { |
| 75 | + void addOperand(OperandOptions options); |
| 76 | + void setOperandValue(unsigned long index, ArrayBufferView data); |
| 77 | + void addOperation(long type, sequence<unsigned long> inputs, sequence<unsigned long> outputs); |
| 78 | + void identifyInputsAndOutputs(sequence<unsigned long> inputs, sequence<unsigned long> outputs); |
| 79 | + Promise<long> finish(); |
| 80 | + Promise<Compilation> createCompilation(); |
| 81 | +}; |
| 82 | + |
| 83 | +interface Compilation { |
| 84 | + void setPreference(long preference); |
| 85 | + Promise<long> finish(); |
| 86 | + Promise<Execution> createExecution(); |
| 87 | +}; |
| 88 | + |
| 89 | +interface Execution { |
| 90 | + void setInput(unsigned long index, ArrayBufferView data); |
| 91 | + void setOutput(unsigned long index, ArrayBufferView data); |
| 92 | + Promise<long> startCompute(); |
| 93 | +}; |
0 commit comments