Skip to content

Commit

Permalink
Switch to readthedocs (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
adityagoel4512 committed Jun 15, 2024
1 parent bd94b71 commit 6105cd6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
10 changes: 10 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
build:
os: "ubuntu-22.04"
commands:
- curl -fsSL https://pixi.sh/install.sh | bash
- chmod +x ~/.pixi/bin/pixi
- ~/.pixi/bin/pixi run -e docs postinstall
- ~/.pixi/bin/pixi run -e docs docs
- mkdir -p $READTHEDOCS_OUTPUT/html/
- cp -r docs/_build/html/** $READTHEDOCS_OUTPUT/html/
45 changes: 22 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,46 +53,45 @@ It has a couple of key features:
xp = a.__array_namespace__()
return xp.mean(a[(low < a) & (a < high)])

arr = [-12.12, 1.12, 2.12, 2.13, 123.,]

np_result = mean_drop_outliers(npx.asarray(arr))
jax_result = mean_drop_outliers(jxp.asarray(arr))
ndx_result = mean_drop_outliers(ndx.asarray(arr))
print(np_result) # 1.79
print(jax_result) # 1.79
print(ndx_result) # Array(1.79, dtype=ndx.Float64)
assert np_result == ndx_result.to_numpy()
np_result = mean_drop_outliers(npx.asarray([-10, 0.5, 1, 5]))
jax_result = mean_drop_outliers(jxp.asarray([-10, 0.5, 1, 5]))
onnx_result = mean_drop_outliers(ndx.asarray([-10, 0.5, 1, 5]))

assert np_result == onnx_result.to_numpy() == jax_result == 0.75
```

- It supports ONNX export. This allows you persist your logic into an ONNX computation graph for convenient and performant inference.
- It supports ONNX export. This allows you persist your logic into an ONNX computation graph.

```python
import onnx
import ndonnx as ndx
import onnx

a = ndx.array(shape=("N",), dtype=ndx.float64)
b = ndx.array(shape=("N",), dtype=ndx.float64)
out = a[:2] + b[:2]
model_proto = ndx.build({"a": a, "b": b}, {"c": out})
onnx.save(model_proto, "model.onnx")
# Instantiate placeholder ndonnx array
x = ndx.array(shape=("N",), dtype=ndx.float32)
y = mean_drop_outliers(x)

# Having serialised your model to disk, perform
# inference using a runtime of your choosing.
# Build and save ONNX model to disk
model = ndx.build({"x": x}, {"y": y})
onnx.save(model, "mean_drop_outliers.onnx")
```

You can then make predictions using a runtime of your choice.

```python
import onnxruntime as ort
import numpy as np
inference_session = ort.InferenceSession("model.onnx")
inference_session = ort.InferenceSession("mean_drop_outliers.onnx")
prediction, = inference_session.run(None, {
"a": np.array([1, 2, 3], dtype=np.float64),
"b": np.array([4, 5, 6], dtype=np.float64),
"x": np.array([-10, 0.5, 1, 5], dtype=np.float32),
})
print(prediction) # array([5., 7.])
assert prediction == 0.75
```

In the future we will be enabling a stable API for an extensible data type system. This will allow users to define their own data types and operations on arrays with these data types.

## Array API coverage

Array API compatibility is tracked in the array-api coverage test suite in `api-coverage-tests`. Missing coverage is tracked in the `skips.txt` file. Contributions are welcome!
Array API compatibility is tracked in `api-coverage-tests`. Missing coverage is tracked in the `skips.txt` file. Contributions are welcome!

Summary(1119 total):

Expand Down

0 comments on commit 6105cd6

Please sign in to comment.