Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bb0fdf9

Browse files
committed
docs: Start of API reference, for emlearn_cnn
1 parent 978b1a7 commit bb0fdf9

File tree

3 files changed

+80
-10
lines changed

3 files changed

+80
-10
lines changed

docs/api_reference.rst

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
.. Places parent toc into the sidebar
3+
:parenttoc: True
4+
5+
.. title:: API: contents
6+
7+
.. _api_reference:
8+
9+
====================
10+
API reference
11+
====================
12+
13+
14+
.. toctree::
15+
:numbered:
16+
:maxdepth: 2
17+
:titlesonly:
18+
19+
20+
emlearn_cnn
21+
------------
22+
23+
.. automodule:: emlearn_cnn
24+
:members:

docs/conf.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
import sys
1818
import subprocess
1919

20-
sys.path.insert(0, os.path.abspath('..'))
20+
# Adjust path so we can find the .py files with API documentation
21+
sys.path.insert(0, os.path.abspath('../stubs'))
2122

2223
# -- Project information -----------------------------------------------------
2324

@@ -44,6 +45,7 @@
4445
'sphinx.ext.mathjax',
4546
'sphinx.ext.viewcode',
4647
'sphinx.ext.autodoc',
48+
'sphinx_autodoc_typehints',
4749
'sphinx.ext.doctest',
4850
'sphinx.ext.coverage',
4951
'sphinx.ext.autosectionlabel',
@@ -200,15 +202,7 @@
200202

201203
# -- Extension configuration -------------------------------------------------
202204

203-
204-
sphinx_gallery_conf = {
205-
'examples_dirs': '../examples', # path to your example scripts
206-
'gallery_dirs': 'auto_examples', # path to where to save gallery generated output
207-
'filename_pattern': '/', # execute all .py files, not just those with plot_ prefix
208-
}
209-
210-
211-
205+
# -- Intersphinx
212206
intersphinx_mapping = {
213207
"emlearn": ("https://emlearn.readthedocs.io/en/latest/", None),
214208
}
@@ -219,3 +213,9 @@
219213
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_disabled_reftypes
220214
intersphinx_disabled_reftypes = ["*"]
221215

216+
# -- autodoc typehints
217+
always_document_param_types = True
218+
typehints_fully_qualified = True
219+
always_use_bars_union = True
220+
221+

stubs/emlearn_cnn.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Stub file (PEP 484) with API definitions and documentation for native module
2+
# Is called .py because Sphinx autodoc currently does not support .pyi files
3+
4+
"""
5+
Convolutional Neural Network module.
6+
7+
Implemented using TinyMaix (https://github.com/sipeed/TinyMaix/).
8+
9+
Note that multiple variants of this module is provided.
10+
So the import should either be **emlearn_cnn_fp32** (for 32 bit floating point),
11+
or **emlearn_cnn_int8** (for 8 bit integers, quantized model).
12+
13+
"""
14+
15+
import array
16+
17+
class Model():
18+
"""A Convolutional Neural Network
19+
20+
Note: May not be constructed directly. Instead use the new() function.
21+
"""
22+
def run(self, inputs : array.array, outputs: array.array):
23+
"""
24+
Run inference using the model
25+
26+
:param inputs: the input data
27+
:param outputs: where to put model outputs
28+
"""
29+
pass
30+
31+
def output_dimensions(self) -> tuple[int]:
32+
"""
33+
Get the output dimensions/size of the model
34+
35+
Useful to know how large an array to pass to run()
36+
"""
37+
pass
38+
39+
def new(model_data : array.array) -> Model:
40+
"""
41+
Construct a new Convolutional Neural Network
42+
43+
:param model_data: The model definition (.TMDL file, as bytes).
44+
"""
45+
pass
46+

0 commit comments

Comments
 (0)