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
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
@@ -831,12 +831,12 @@ Its <a>default allowlist</a> is <code>'self'</code>.
831
831
1. Let |context| be a new {{MLContext}} object.
832
832
1. If |options| is a {{GPUDevice}} object,
833
833
1. Set |context|.{{[[contextType]]}} to "[=context type/webgpu=]".
834
-
1. Set |context|.{{[[deviceType]]}} to "[=device type/gpu=]".
835
-
1. Set |context|.{{[[powerPreference]]}} to "[=power preference/default=]".
834
+
1. Set |context|.{{[[deviceType]]}} to {{MLDeviceType/"gpu"}}.
835
+
1. Set |context|.{{[[powerPreference]]}} to {{MLPowerPreference/"default"}}.
836
836
1. Otherwise,
837
837
1. Set |context|.{{[[contextType]]}} to "[=context type/default=]".
838
-
1. If |options|["{{deviceType}}"][=map/exists=], then set |context|.{{[[deviceType]]}} to |options|["{{deviceType}}"]. Otherwise, set |context|.{{[[deviceType]]}} to "[=device type/cpu=]".
839
-
1. If |options|["{{powerPreference}}"][=map/exists=], then set |context|.{{[[powerPreference]]}} to |options|["{{powerPreference}}"]. Otherwise, set |context|.{{[[powerPreference]]}} to "[=power preference/default=]".
838
+
1. If |options|["{{deviceType}}"][=map/exists=], then set |context|.{{[[deviceType]]}} to |options|["{{deviceType}}"]. Otherwise, set |context|.{{[[deviceType]]}} to {{MLDeviceType/"cpu"}}.
839
+
1. If |options|["{{powerPreference}}"][=map/exists=], then set |context|.{{[[powerPreference]]}} to |options|["{{powerPreference}}"]. Otherwise, set |context|.{{[[powerPreference]]}} to {{MLPowerPreference/"default"}}.
840
840
1. If the user agent cannot support |context|.{{[[contextType]]}}, |context|.{{[[deviceType]]}} and |context|.{{[[powerPreference]]}}, return failure.
841
841
1. Return |context|.
842
842
</div>
@@ -1089,20 +1089,20 @@ The <dfn>context type</dfn> is the type of the execution context that manages th
1089
1089
</dl>
1090
1090
1091
1091
The <dfn>device type</dfn> indicates the kind of device used for the context. It is one of the following:
1092
-
<dl dfn-for="device type">
1093
-
<dt>"<dfn>cpu</dfn>"</dt>
1092
+
<dl dfn-for="MLDeviceType">
1093
+
<dt>"<dfn enum-value>cpu</dfn>"</dt>
1094
1094
<dd>Provides the broadest compatibility and usability across all client devices with varying degrees of performance.</dd>
1095
-
<dt>"<dfn>gpu</dfn>"</dt>
1095
+
<dt>"<dfn enum-value>gpu</dfn>"</dt>
1096
1096
<dd>Provides the broadest range of achievable performance across graphics hardware platforms from consumer devices to professional workstations.</dd>
1097
1097
</dl>
1098
1098
1099
1099
The <dfn>power preference</dfn> indicates preference as related to power consumption. It is one of the following:
1100
-
<dl dfn-for="power preference">
1101
-
<dt>"<dfn>default</dfn>"</dt>
1100
+
<dl dfn-for="MLPowerPreference">
1101
+
<dt>"<dfn enum-value>default</dfn>"</dt>
1102
1102
<dd>Let the user agent select the most suitable behavior.</dd>
1103
-
<dt>"<dfn ignore>high-performance</dfn>"</dt>
1103
+
<dt>"<dfn enum-value>high-performance</dfn>"</dt>
1104
1104
<dd>Prioritizes execution speed over power consumption.</dd>
1105
-
<dt>"<dfn ignore>low-power</dfn>"</dt>
1105
+
<dt>"<dfn enum-value>low-power</dfn>"</dt>
1106
1106
<dd>Prioritizes power consumption over other considerations such as execution speed.</dd>
1107
1107
</dl>
1108
1108
@@ -1129,7 +1129,7 @@ interface MLContext {};
1129
1129
</div>
1130
1130
1131
1131
<div class="note">
1132
-
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.
1132
+
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