Skip to content

Commit ca85171

Browse files
committed
Add Scope section
1 parent 9f9ec6b commit ca85171

File tree

3 files changed

+156
-2
lines changed

3 files changed

+156
-2
lines changed
83.5 KB
Loading

spec/purpose_and_scope.md

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,151 @@
33
## Introduction
44

55

6+
### This API standard
7+
68

79
## History
810

911

1012

1113
## Scope (includes out-of-scope / non-goals)
1214

15+
This section outlines what is in scope and out of scope for this API standard.
16+
17+
### In scope
18+
19+
The scope of the array API standard includes:
20+
21+
- Functionality which needs to be included in an array library for it to adhere
22+
to this standard.
23+
- Names of functions, methods, classes and other objects.
24+
- Function signatures, including type annotations.
25+
- Semantics of functions and methods. I.e. expected outputs including precision
26+
for and dtypes of numerical results.
27+
- Semantics in the presence of `nan`'s, `inf`'s, empty arrays (i.e. arrays
28+
including one or more dimensions of size `0`).
29+
- Casting rules, broadcasting, indexing
30+
- Data interchange. I.e. protocols to convert one type of array into another
31+
type, potentially sharing memory.
32+
33+
Furthermore, meta-topics included in this standard include:
34+
35+
- Use cases for the API standard and assumptions made in it
36+
- API standard adoption
37+
- API standard versioning
38+
- Future API standard evolution
39+
- Array library and API standard versioning
40+
- Verification of API standard conformance
41+
42+
The concrete set of functionality that is in scope for this version of the
43+
standard is shown in this diagram (_TODO: update after deciding on how optional
44+
extensions are dealt with_):
45+
46+
![Scope of array API](_static/images/scope_of_array_API.png)
47+
48+
49+
**Goals** for the API standard include:
50+
51+
- Make it possible for array-consuming libraries to start using multiple types
52+
of arrays as inputs.
53+
- Enable more sharing and reuse of code built on top of the core functionality
54+
in the API standard.
55+
- For authors of new array libraries, provide a concrete API that can be
56+
adopted as is, rather than each author having to decide what to borrow from
57+
where and where to deviate.
58+
- Make the learning curve for users less steep when they switch from one array
59+
library to another one.
60+
61+
62+
### Out of scope
63+
64+
1. Implementations of the standard are out of scope.
65+
66+
_Rationale: the standard will consist of a document and an accompanying test
67+
suite with which the conformance of an implementation can be verified. Actual
68+
implementations will live in array libraries; no reference implementation is
69+
planned._
70+
71+
2. Execution semantics are out of scope. This includes single-threaded vs.
72+
parallel execution, task scheduling and synchronization, eager vs. delayed
73+
evaluation, performance characteristics of a particular implementation of the
74+
standard, and other such topics.
75+
76+
_Rationale: execution is the domain of implementations. Attempting to specify
77+
execution behavior in a standard is likely to require much more fine-grained
78+
coordination between developers of implementations, and hence is likely to
79+
become an obstable to adoption._
80+
81+
3. Non-Python API standardization (e.g., Cython or NumPy C APIs)
82+
83+
_Rationale: this is an important topic for some array-consuming libraries,
84+
but there is no widely shared C/Cython API and hence it doesn't make sense at
85+
this point in time to standardize anything. See
86+
[the C API section](design_topics/C_API.md) for more details._
87+
88+
4. Standardization of these dtypes is out of scope: bfloat16, complex, extended
89+
precision floating point, datetime, string, object and void dtypes.
90+
91+
_Rationale: these dtypes aren't uniformly supported, and their inclusion at
92+
this point in time could put a significant implementation burden on
93+
libraries. It is expected that some of these dtypes - in particular
94+
`bfloat16`, `complex64`, and `complex128` - will be included in a future
95+
version of the standard._
96+
97+
5. The following topics are out of scope: I/O, polynomials, error handling,
98+
testing routines, building and packaging related functionality, methods of
99+
binding compiled code (e.g., `cffi`, `ctypes`), subclassing of an array
100+
class, masked arrays, and missing data.
101+
102+
_Rationale: these topics are not core functionality for an array library,
103+
and/or are too tied to implementation details._
104+
105+
6. NumPy (generalized) universal functions, i.e. ufuncs and gufuncs.
106+
107+
_Rationale: these are NumPy-specific concepts, and are mostly just a
108+
particular way of building regular functions with a few extra
109+
methods/properties._
110+
111+
112+
**Non-goals** for the API standard include:
113+
114+
- Making array libraries identical so they can be merged.
115+
116+
_Each library will keep having its own particular strength, whether it's
117+
offering functionality beyond what's in the standard, performance advantages
118+
for a given use case, specific hardware or software environment support, or
119+
more._
120+
121+
- Implement a backend or runtime switching system to be able to switch from one
122+
array library to another with a single setting or line of code.
123+
124+
_This may be feasible, however it's assumed that when an array-consuming
125+
library switches from one array type to another, some testing and possibly
126+
code adjustment for performance or other reasons may be needed._
127+
128+
129+
### TBD whether or not in scope, or for a later version
130+
131+
- Device support (related to array creation on a specific device).
132+
133+
_This can be important, however there's no uniform syntax for it currently
134+
and it may not make sense to add such syntax to libraries that only support a
135+
single device type._
136+
137+
- Random number generation, Fourier transforms, and miscellaneous functionality
138+
like a padding function.
139+
140+
_This will be decided later, depending on whether "optional extensions" will
141+
be added to the standard._
142+
143+
144+
### Implications of in/out of scope
145+
146+
If something is out of scope and therefore will not be part of (the current
147+
version of) the API standard, that means that there are no guarantees that that
148+
functionality works the same way, or even exists at all, across the set of
149+
array libraries that conform to the standard. It does _not_ imply that this
150+
functionality is less important or should not be used.
13151

14152

15153
## Stakeholders
@@ -104,9 +242,19 @@ For guidance on how to read and understand the type annotations included in this
104242

105243
## Conformance
106244

107-
A conforming implementation of the array API standard must provide and support all the functions, arguments, data types, syntax, and semantics described in this specification.
245+
A conforming implementation of the array API standard must provide and support
246+
all the functions, arguments, data types, syntax, and semantics described in
247+
this specification.
248+
249+
A conforming implementation of the array API standard may provide additional
250+
values, objects, properties, data types, and functions beyond those described
251+
in this specification.
252+
253+
Libraries which aim to provide a conforming implementation but haven't yet
254+
completed such an implementation may, and are encouraged to, provide details on
255+
the level of (non-)conformance. For details on how to do this, see
256+
[Verification - measuring conformance](verification_test_suite.md).
108257

109-
A conforming implementation of the array API standard may provide additional values, objects, properties, data types, and functions beyond those described in this specification.
110258

111259
* * *
112260

spec/verification_test_suite.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# Verification - test suite
22

3+
4+
5+
## Measuring conformance
6+
7+
TODO: explain how to use the test suite to measure and report on the level of
8+
(non-)conformance.

0 commit comments

Comments
 (0)