Skip to content

Commit 50d793b

Browse files
author
array-api-bot
committed
Deploy: 2d3abf7
1 parent fb7a2cb commit 50d793b

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

draft/_sources/design_topics/device_support.rst.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ rather than hard requirements:
7777
- Respect explicit device assignment (i.e. if the input to the ``device=`` keyword is not ``None``, guarantee that the array is created on the given device, and raise an exception otherwise).
7878
- Preserve device assignment as much as possible (e.g. output arrays from a function are expected to be on the same device as input arrays to the function).
7979
- Raise an exception if an operation involves arrays on different devices (i.e. avoid implicit data transfer between devices).
80+
- When a function accepts a mix of arrays and Python scalars, the scalars should inherit the device of the arrays, much like what happens with :ref:`type-promotion`.
8081
- Use a default for ``device=None`` which is consistent between functions within the same library.
81-
- If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority. For example:
82+
- If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority:
8283

83-
1. If ``device=`` keyword is specified, that always takes precedence
84-
85-
2. If ``device=None``, then use the setting from a context manager, if set.
86-
87-
3. If no context manager was used, then use the global default device/strategy
84+
1. If the ``device=`` keyword is specified, that always takes precedence;
85+
2. If ``device=None`` or the function does not accept a ``device`` parameter, then use the device of the input array(s), if any;
86+
3. If there are no input arrays, then use the setting from a context manager, if any;
87+
4. If no context manager was used, then use the global default device/strategy.
8888

8989
.. _device-out-of-scope:
9090

draft/design_topics/device_support.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,14 @@ <h2 id="semantics">Semantics<a class="headerlink" href="#semantics" title="Link
503503
<li><p>Respect explicit device assignment (i.e. if the input to the <code class="docutils literal notranslate"><span class="pre">device=</span></code> keyword is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, guarantee that the array is created on the given device, and raise an exception otherwise).</p></li>
504504
<li><p>Preserve device assignment as much as possible (e.g. output arrays from a function are expected to be on the same device as input arrays to the function).</p></li>
505505
<li><p>Raise an exception if an operation involves arrays on different devices (i.e. avoid implicit data transfer between devices).</p></li>
506+
<li><p>When a function accepts a mix of arrays and Python scalars, the scalars should inherit the device of the arrays, much like what happens with <a class="reference internal" href="../API_specification/type_promotion.html#type-promotion"><span class="std std-ref">Type Promotion Rules</span></a>.</p></li>
506507
<li><p>Use a default for <code class="docutils literal notranslate"><span class="pre">device=None</span></code> which is consistent between functions within the same library.</p></li>
507-
<li><p>If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority. For example:</p>
508+
<li><p>If a library has multiple ways of controlling device placement, the most explicit method should have the highest priority:</p>
508509
<ol class="arabic simple">
509-
<li><p>If <code class="docutils literal notranslate"><span class="pre">device=</span></code> keyword is specified, that always takes precedence</p></li>
510-
<li><p>If <code class="docutils literal notranslate"><span class="pre">device=None</span></code>, then use the setting from a context manager, if set.</p></li>
511-
<li><p>If no context manager was used, then use the global default device/strategy</p></li>
510+
<li><p>If the <code class="docutils literal notranslate"><span class="pre">device=</span></code> keyword is specified, that always takes precedence;</p></li>
511+
<li><p>If <code class="docutils literal notranslate"><span class="pre">device=None</span></code> or the function does not accept a <code class="docutils literal notranslate"><span class="pre">device</span></code> parameter, then use the device of the input array(s), if any;</p></li>
512+
<li><p>If there are no input arrays, then use the setting from a context manager, if any;</p></li>
513+
<li><p>If no context manager was used, then use the global default device/strategy.</p></li>
512514
</ol>
513515
</li>
514516
</ul>

draft/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)