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
Wording change: Define power prefs & device type using WebIDL enums (#535)
Replace definitions for MLContext's device type and power preference
which are used internally only, with the identical WebIDL-defined
MLDeviceType and MLPowerPreference enums.
Fixes#497
Copy file name to clipboardexpand all lines: index.bs
+12-12
Original file line number
Diff line number
Diff line change
@@ -833,12 +833,12 @@ Its <a>default allowlist</a> is <code>'self'</code>.
833
833
1. Let |context| be a new {{MLContext}} object.
834
834
1. If |options| is a {{GPUDevice}} object,
835
835
1. Set |context|.{{[[contextType]]}} to "[=context type/webgpu=]".
836
-
1. Set |context|.{{[[deviceType]]}} to "[=device type/gpu=]".
837
-
1. Set |context|.{{[[powerPreference]]}} to "[=power preference/default=]".
836
+
1. Set |context|.{{[[deviceType]]}} to {{MLDeviceType/"gpu"}}.
837
+
1. Set |context|.{{[[powerPreference]]}} to {{MLPowerPreference/"default"}}.
838
838
1. Otherwise,
839
839
1. Set |context|.{{[[contextType]]}} to "[=context type/default=]".
840
-
1. If |options|["{{deviceType}}"][=map/exists=], then set |context|.{{[[deviceType]]}} to |options|["{{deviceType}}"]. Otherwise, set |context|.{{[[deviceType]]}} to "[=device type/cpu=]".
841
-
1. If |options|["{{powerPreference}}"][=map/exists=], then set |context|.{{[[powerPreference]]}} to |options|["{{powerPreference}}"]. Otherwise, set |context|.{{[[powerPreference]]}} to "[=power preference/default=]".
840
+
1. If |options|["{{deviceType}}"][=map/exists=], then set |context|.{{[[deviceType]]}} to |options|["{{deviceType}}"]. Otherwise, set |context|.{{[[deviceType]]}} to {{MLDeviceType/"cpu"}}.
841
+
1. If |options|["{{powerPreference}}"][=map/exists=], then set |context|.{{[[powerPreference]]}} to |options|["{{powerPreference}}"]. Otherwise, set |context|.{{[[powerPreference]]}} to {{MLPowerPreference/"default"}}.
842
842
1. If the user agent cannot support |context|.{{[[contextType]]}}, |context|.{{[[deviceType]]}} and |context|.{{[[powerPreference]]}}, return failure.
843
843
1. Return |context|.
844
844
</div>
@@ -1091,20 +1091,20 @@ The <dfn>context type</dfn> is the type of the execution context that manages th
1091
1091
</dl>
1092
1092
1093
1093
The <dfn>device type</dfn> indicates the kind of device used for the context. It is one of the following:
1094
-
<dl dfn-for="device type">
1095
-
<dt>"<dfn>cpu</dfn>"</dt>
1094
+
<dl dfn-for="MLDeviceType">
1095
+
<dt>"<dfn enum-value>cpu</dfn>"</dt>
1096
1096
<dd>Provides the broadest compatibility and usability across all client devices with varying degrees of performance.</dd>
1097
-
<dt>"<dfn>gpu</dfn>"</dt>
1097
+
<dt>"<dfn enum-value>gpu</dfn>"</dt>
1098
1098
<dd>Provides the broadest range of achievable performance across graphics hardware platforms from consumer devices to professional workstations.</dd>
1099
1099
</dl>
1100
1100
1101
1101
The <dfn>power preference</dfn> indicates preference as related to power consumption. It is one of the following:
1102
-
<dl dfn-for="power preference">
1103
-
<dt>"<dfn>default</dfn>"</dt>
1102
+
<dl dfn-for="MLPowerPreference">
1103
+
<dt>"<dfn enum-value>default</dfn>"</dt>
1104
1104
<dd>Let the user agent select the most suitable behavior.</dd>
1105
-
<dt>"<dfn ignore>high-performance</dfn>"</dt>
1105
+
<dt>"<dfn enum-value>high-performance</dfn>"</dt>
1106
1106
<dd>Prioritizes execution speed over power consumption.</dd>
1107
-
<dt>"<dfn ignore>low-power</dfn>"</dt>
1107
+
<dt>"<dfn enum-value>low-power</dfn>"</dt>
1108
1108
<dd>Prioritizes power consumption over other considerations such as execution speed.</dd>
1109
1109
</dl>
1110
1110
@@ -1131,7 +1131,7 @@ interface MLContext {};
1131
1131
</div>
1132
1132
1133
1133
<div class="note">
1134
-
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.
1134
+
When the {{[[contextType]]}} is set to [=context type/default=] with the {{MLContextOptions}}.{{deviceType}} set to {{MLDeviceType/"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.
0 commit comments