Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe what extensions are and how to use them #470

Merged
merged 1 commit into from
Nov 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions spec/extensions/index.rst
Original file line number Diff line number Diff line change
@@ -3,8 +3,29 @@
Extensions
==========

Extensions are coherent sets of functionality that are commonly implemented
across array libraries. Each array library supporting this standard may, but is
not required to, implement an extension. If an extension is supported, it
must be accessible inside the main array API supporting namespace as a separate
namespace.

Extension module implementors must aim to provide all functions and other
public objects in an extension. The rationale for this is that downstream usage
can then check whether or not the extension is present (using ``hasattr(xp,
'extension_name')`` should be enough), and can then assume that functions are
implemented. This in turn makes it also easy for array-consuming libraries to
document which array libraries they support - e.g., "all libraries implementing
the array API standard and its linear algebra extension".

The mechanism through which the extension namespace is made available is up to
the implementer, e.g. via a regular submodule that is imported under the
``linalg`` name, or via a module-level ``__getattr__``.


Extensions
----------

.. toctree::
:caption: Extensions
:maxdepth: 3
:maxdepth: 1

linear_algebra_functions
17 changes: 17 additions & 0 deletions spec/extensions/linear_algebra_functions.rst
Original file line number Diff line number Diff line change
@@ -5,6 +5,23 @@ Linear Algebra Extension

Array API specification for linear algebra functions.

Extension name and usage
------------------------

The name of the namespace providing the extension must be: ``linalg``.

If implemented, this ``linalg`` extension must be retrievable via::

>>> xp = x.__array_namespace__()
>>> if hasattr(xp, 'linalg'):
>>> # Use `xp.linalg`


General syntax and semantics rules
----------------------------------

.. TODO: get rid of this here, it's duplicated over and over
A conforming implementation of the array API standard must provide and support the following functions adhering to the following conventions.

- Positional parameters must be `positional-only <https://www.python.org/dev/peps/pep-0570/>`_ parameters. Positional-only parameters have no externally-usable name. When a function accepting positional-only parameters is called, positional arguments are mapped to these parameters based solely on their order.