Skip to content

Commit 7773794

Browse files
authored
Merge pull request #499 from inexorabletash/scopeenums
Stylistic change: Replace some explicit use of link target naming with scopes
2 parents fa91851 + b154e54 commit 7773794

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

index.bs

+23-23
Original file line numberDiff line numberDiff line change
@@ -793,13 +793,13 @@ Its <a>default allowlist</a> is <code>'self'</code>.
793793
<div class=algorithm-steps>
794794
1. Let |context| be a new {{MLContext}} object.
795795
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 "[=device type/gpu=]".
798+
1. Set |context|.{{[[powerPreference]]}} to "[=power preference/default=]".
799799
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 "[=device type/cpu=]".
802+
1. If |options|["{{powerPreference}}"] [=map/exists=], then set |context|.{{[[powerPreference]]}} to |options|["{{powerPreference}}"]. Otherwise, set |context|.{{[[powerPreference]]}} to "[=power preference/default=]".
803803
1. Return |context|.
804804
</div>
805805
</details>
@@ -1047,28 +1047,28 @@ partial interface MLCommandEncoder {
10471047
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=].
10481048

10491049
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:
1050-
<dl>
1051-
<dt>"<code><dfn data-lt="default-context">default</dfn></code>"</dt>
1050+
<dl dfn-for="context type">
1051+
<dt>"<dfn>default</dfn>"</dt>
10521052
<dd>Context created per user preference options.</dd>
1053-
<dt>"<code><dfn data-lt="webgpu-context">webgpu</dfn></code>"</dt>
1053+
<dt>"<dfn>webgpu</dfn>"</dt>
10541054
<dd>Context created from WebGPU device.</dd>
10551055
</dl>
10561056

10571057
The <dfn>device type</dfn> indicates the kind of device used for the context. It is one of the following:
1058-
<dl>
1059-
<dt>"<code><dfn data-lt="device-type-cpu">cpu</dfn></code>"</dt>
1058+
<dl dfn-for="device type">
1059+
<dt>"<dfn>cpu</dfn>"</dt>
10601060
<dd>Provides the broadest compatibility and usability across all client devices with varying degrees of performance.</dd>
1061-
<dt>"<code><dfn data-lt="device-type-gpu">gpu</dfn></code>"</dt>
1061+
<dt>"<dfn>gpu</dfn>"</dt>
10621062
<dd>Provides the broadest range of achievable performance across graphics hardware platforms from consumer devices to professional workstations.</dd>
10631063
</dl>
10641064

10651065
The <dfn>power preference</dfn> indicates preference as related to power consumption. It is one of the following:
1066-
<dl>
1067-
<dt>"<code><dfn data-lt="power-preference-default">default</dfn></code>"</dt>
1066+
<dl dfn-for="power preference">
1067+
<dt>"<dfn>default</dfn>"</dt>
10681068
<dd>Let the user agent select the most suitable behavior.</dd>
1069-
<dt>"<code><dfn data-lt="power-preference-high-performance">high-performance</dfn></code>"</dt>
1069+
<dt>"<dfn>high-performance</dfn>"</dt>
10701070
<dd>Prioritizes execution speed over power consumption.</dd>
1071-
<dt>"<code><dfn data-lt="power-preference-low-power">low-power</dfn></code>"</dt>
1071+
<dt>"<dfn>low-power</dfn>"</dt>
10721072
<dd>Prioritizes power consumption over other considerations such as execution speed.</dd>
10731073
</dl>
10741074

@@ -1095,7 +1095,7 @@ interface MLContext {};
10951095
</div>
10961096

10971097
<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 [=device type/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.
10991099
</div>
11001100

11011101
### {{MLContext}} validation algorithm ### {#api-mlcontext-validate}
@@ -1105,9 +1105,9 @@ When the {{[[contextType]]}} is set to [=default-context|default=] with the {{ML
11051105
To <dfn>validate MLContext</dfn>, given |context|, run these steps:
11061106
</summary>
11071107
<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 "[=device type/cpu=]" or "[=device type/gpu=]", return false.
1110+
1. If |context|.{{[[powerPreference]]}} is not "[=power preference/default=]" or "[=power preference/high-performance=]" or "[=power preference/low-power=]", return false.
11111111
1. If the user agent cannot support |context|.{{[[contextType]]}}, |context|.{{[[deviceType]]}} and |context|.{{[[powerPreference]]}}, return false.
11121112
1. Return true;
11131113
</div>
@@ -1138,7 +1138,7 @@ partial interface MLContext {
11381138
The <dfn method for=MLContext>computeSync(|graph|, |inputs|, |outputs|)</dfn> method steps are:
11391139
</summary>
11401140
<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}}.
11421142
1. If [=validating graph resources=] given |inputs| and |graph|.{{MLGraph/[[inputDescriptors]]}} returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
11431143
1. If [=validating graph resources=] given |outputs| and |graph|.{{MLGraph/[[outputDescriptors]]}} returns false, then [=exception/throw=] a "{{DataError}}" {{DOMException}}.
11441144
1. Invoke [=execute graph=] given |graph|, |inputs| and |outputs|.
@@ -1286,7 +1286,7 @@ partial interface MLContext {
12861286
<div class=algorithm-steps>
12871287
1. Let |promise| be [=a new promise=].
12881288
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}}.
12901290
1. If [=validating graph resources=] given |inputs| and |graph|.{{MLGraph/[[inputDescriptors]]}} returns false, then [=reject=] |promise| with a "{{DataError}}" {{DOMException}}.
12911291
1. If [=validating graph resources=] given |outputs| and |graph|.{{MLGraph/[[outputDescriptors]]}} returns false, then [=reject=] |promise| with a "{{DataError}}" {{DOMException}}.
12921292
1. Let |transferredInputs| be the result of [=MLNamedArrayBufferViews/transfer|transferring=] {{MLNamedArrayBufferViews}} |inputs|.
@@ -1415,7 +1415,7 @@ interface MLGraphBuilder {
14151415
</script>
14161416

14171417
<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.
14191419
</div>
14201420

14211421
{{MLBufferResourceView}} has the following members:

0 commit comments

Comments
 (0)