You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: index.bs
+23-23
Original file line number
Diff line number
Diff line change
@@ -793,13 +793,13 @@ Its <a>default allowlist</a> is <code>'self'</code>.
793
793
<div class=algorithm-steps>
794
794
1. Let |context| be a new {{MLContext}} object.
795
795
1. If |options| is a {{GPUDevice}} object,
796
-
1. Set |context|.{{[[contextType]]}} to "[=webgpu-context|webgpu=]".
797
-
1. Set |context|.{{[[deviceType]]}} to "[=device-type-gpu|gpu=]".
798
-
1. Set |context|.{{[[powerPreference]]}} to "[=power-preference-default|default=]".
796
+
1. Set |context|.{{[[contextType]]}} to "[=context type/webgpu=]".
797
+
1. Set |context|.{{[[deviceType]]}} to "[=devicetype/gpu=]".
798
+
1. Set |context|.{{[[powerPreference]]}} to "[=powerpreference/default=]".
799
799
1. Otherwise,
800
-
1. Set |context|.{{[[contextType]]}} to "[=default-context|default=]".
801
-
1. If |options|["{{deviceType}}"][=map/exists=], then set |context|.{{[[deviceType]]}} to |options|["{{deviceType}}"]. Otherwise, set |context|.{{[[deviceType]]}} to "[=device-type-cpu|cpu=]".
802
-
1. If |options|["{{powerPreference}}"][=map/exists=], then set |context|.{{[[powerPreference]]}} to |options|["{{powerPreference}}"]. Otherwise, set |context|.{{[[powerPreference]]}} to "[=power-preference-default|default=]".
800
+
1. Set |context|.{{[[contextType]]}} to "[=context type/default=]".
801
+
1. If |options|["{{deviceType}}"][=map/exists=], then set |context|.{{[[deviceType]]}} to |options|["{{deviceType}}"]. Otherwise, set |context|.{{[[deviceType]]}} to "[=devicetype/cpu=]".
802
+
1. If |options|["{{powerPreference}}"][=map/exists=], then set |context|.{{[[powerPreference]]}} to |options|["{{powerPreference}}"]. Otherwise, set |context|.{{[[powerPreference]]}} to "[=powerpreference/default=]".
The {{MLContext}} interface represents a global state of neural network compute workload and execution processes. Each {{MLContext}} object has associated [=context type=], [=device type=] and [=power preference=].
1048
1048
1049
1049
The <dfn>context type</dfn> is the type of the execution context that manages the resources and facilitates the compilation and execution of the neural network graph:
<dd>Prioritizes power consumption over other considerations such as execution speed.</dd>
1073
1073
</dl>
1074
1074
@@ -1095,7 +1095,7 @@ interface MLContext {};
1095
1095
</div>
1096
1096
1097
1097
<div class="note">
1098
-
When the {{[[contextType]]}} is set to [=default-context|default=] with the {{MLContextOptions}}.{{deviceType}} set to [=device-type-gpu|gpu=], the user agent is responsible for creating an internal GPU device that operates within the context and is capable of ML workload submission on behalf of the calling application. In this setting however, only {{ArrayBufferView}} inputs and outputs are allowed in and out of the graph execution since the application has no way to know what type of internal GPU device is being created on their behalf. In this case, the user agent is responsible for automatic uploads and downloads of the inputs and outputs to and from the GPU memory using this said internal device.
1098
+
When the {{[[contextType]]}} is set to [=context type/default=] with the {{MLContextOptions}}.{{deviceType}} set to [=devicetype/gpu=], the user agent is responsible for creating an internal GPU device that operates within the context and is capable of ML workload submission on behalf of the calling application. In this setting however, only {{ArrayBufferView}} inputs and outputs are allowed in and out of the graph execution since the application has no way to know what type of internal GPU device is being created on their behalf. In this case, the user agent is responsible for automatic uploads and downloads of the inputs and outputs to and from the GPU memory using this said internal device.
@@ -1105,9 +1105,9 @@ When the {{[[contextType]]}} is set to [=default-context|default=] with the {{ML
1105
1105
To <dfn>validate MLContext</dfn>, given |context|, run these steps:
1106
1106
</summary>
1107
1107
<div class=algorithm-steps>
1108
-
1. If |context|.{{[[contextType]]}} is not "[=webgpu-context|webgpu=]" or "[=default-context|default=]", return false.
1109
-
1. If |context|.{{[[deviceType]]}} is not "[=device-type-cpu|cpu=]" or "[=device-type-gpu|gpu=]", return false.
1110
-
1. If |context|.{{[[powerPreference]]}} is not "[=power-preference-default|default=]" or "[=power-preference-high-performance|high-performance=]" or "[=power-preference-low-power|low-power=]", return false.
1108
+
1. If |context|.{{[[contextType]]}} is not "[=context type/webgpu=]" or "[=context type/default=]", return false.
1109
+
1. If |context|.{{[[deviceType]]}} is not "[=devicetype/cpu=]" or "[=devicetype/gpu=]", return false.
1110
+
1. If |context|.{{[[powerPreference]]}} is not "[=powerpreference/default=]" or "[=powerpreference/high-performance=]" or "[=powerpreference/low-power=]", return false.
1111
1111
1. If the user agent cannot support |context|.{{[[contextType]]}}, |context|.{{[[deviceType]]}} and |context|.{{[[powerPreference]]}}, return false.
The <dfn method for=MLContext>computeSync(|graph|, |inputs|, |outputs|)</dfn> method steps are:
1139
1139
</summary>
1140
1140
<div class=algorithm-steps>
1141
-
1. If |graph|.{{MLGraph/[[context]]}}.{{MLContext/[[contextType]]}} is not "[=default-context|default=]", [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1141
+
1. If |graph|.{{MLGraph/[[context]]}}.{{MLContext/[[contextType]]}} is not "[=context type/default=]", [=exception/throw=] an "{{OperationError}}" {{DOMException}}.
1142
1142
1. If [=validating graph resources=] given |inputs| and |graph|.{{MLGraph/[[inputDescriptors]]}} returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1143
1143
1. If [=validating graph resources=] given |outputs| and |graph|.{{MLGraph/[[outputDescriptors]]}} returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
1144
1144
1. Invoke [=execute graph=] given |graph|, |inputs| and |outputs|.
1. Return |promise| and run the following steps [=in parallel=]:
1289
-
1. If |graph|.{{MLGraph/[[context]]}}.{{MLContext/[[contextType]]}} is not "[=default-context|default=]", [=reject=] |promise| with an "{{OperationError}}" {{DOMException}}.
1289
+
1. If |graph|.{{MLGraph/[[context]]}}.{{MLContext/[[contextType]]}} is not "[=context type/default=]", [=reject=] |promise| with an "{{OperationError}}" {{DOMException}}.
1290
1290
1. If [=validating graph resources=] given |inputs| and |graph|.{{MLGraph/[[inputDescriptors]]}} returns false, then [=reject=] |promise| with a "{{DataError}}" {{DOMException}}.
1291
1291
1. If [=validating graph resources=] given |outputs| and |graph|.{{MLGraph/[[outputDescriptors]]}} returns false, then [=reject=] |promise| with a "{{DataError}}" {{DOMException}}.
1292
1292
1. Let |transferredInputs| be the result of [=MLNamedArrayBufferViews/transfer|transferring=]{{MLNamedArrayBufferViews}} |inputs|.
@@ -1415,7 +1415,7 @@ interface MLGraphBuilder {
1415
1415
</script>
1416
1416
1417
1417
<div class="note">
1418
-
Both {{MLGraphBuilder}}.{{MLGraphBuilder/build()}} and {{MLGraphBuilder}}.{{MLGraphBuilder/buildSync()}} methods compile the graph builder state up to the specified output operands into a compiled graph according to the type of {{MLContext}} that creates it. Since this operation can be costly in some machine configurations, the calling thread of the {{MLGraphBuilder}}.{{MLGraphBuilder/buildSync()}} method must only be a worker thread to avoid potential disruption of the user experience. When the {{[[contextType]]}} of the {{MLContext}} is set to "[=default-context|default=]", the compiled graph is initialized right before the {{MLGraph}} is returned. This graph initialization stage is important for optimal performance of the subsequent graph executions. See [[#api-mlcommandencoder-graph-initialization]] for more detail.
1418
+
Both {{MLGraphBuilder}}.{{MLGraphBuilder/build()}} and {{MLGraphBuilder}}.{{MLGraphBuilder/buildSync()}} methods compile the graph builder state up to the specified output operands into a compiled graph according to the type of {{MLContext}} that creates it. Since this operation can be costly in some machine configurations, the calling thread of the {{MLGraphBuilder}}.{{MLGraphBuilder/buildSync()}} method must only be a worker thread to avoid potential disruption of the user experience. When the {{[[contextType]]}} of the {{MLContext}} is set to "[=context type/default=]", the compiled graph is initialized right before the {{MLGraph}} is returned. This graph initialization stage is important for optimal performance of the subsequent graph executions. See [[#api-mlcommandencoder-graph-initialization]] for more detail.
1419
1419
</div>
1420
1420
1421
1421
{{MLBufferResourceView}} has the following members:
0 commit comments