From 4a7d939bd0ef6ba7c3a8817296c1ad649056db77 Mon Sep 17 00:00:00 2001 From: Benoit Chevallier-Mames Date: Tue, 7 Dec 2021 17:51:12 +0100 Subject: [PATCH] docs: update the documentation refs #1085 --- Makefile | 4 +- docs/user/index.rst | 1 + docs/user/tutorial/NUMPY_SUPPORT.md | 135 ++++++++++++++++++ .../tutorial/WORKING_WITH_FLOATING_POINTS.md | 90 +----------- script/doc_utils/gen_supported_ufuncs.py | 3 + 5 files changed, 142 insertions(+), 91 deletions(-) create mode 100644 docs/user/tutorial/NUMPY_SUPPORT.md diff --git a/Makefile b/Makefile index ef409623b..a660b8a0f 100644 --- a/Makefile +++ b/Makefile @@ -320,11 +320,11 @@ todo: .PHONY: supported_functions # Update docs with supported functions supported_functions: - poetry run python script/doc_utils/gen_supported_ufuncs.py docs/user/tutorial/WORKING_WITH_FLOATING_POINTS.md + poetry run python script/doc_utils/gen_supported_ufuncs.py docs/user/tutorial/NUMPY_SUPPORT.md .PHONY: check_supported_functions # Check supported functions (for the doc) check_supported_functions: - poetry run python script/doc_utils/gen_supported_ufuncs.py docs/user/tutorial/WORKING_WITH_FLOATING_POINTS.md --check + poetry run python script/doc_utils/gen_supported_ufuncs.py docs/user/tutorial/NUMPY_SUPPORT.md --check .PHONY: licences # Generate the list of licenses of dependencies licences: diff --git a/docs/user/index.rst b/docs/user/index.rst index 33b56017d..d47d4646f 100644 --- a/docs/user/index.rst +++ b/docs/user/index.rst @@ -18,6 +18,7 @@ Getting Started tutorial/ARITHMETIC_OPERATIONS.md tutorial/TABLE_LOOKUP.md tutorial/WORKING_WITH_FLOATING_POINTS.md + tutorial/NUMPY_SUPPORT.md tutorial/INDEXING.md tutorial/MACHINE_LEARNING_TOOLS.md tutorial/COMPILATION_ARTIFACTS.md diff --git a/docs/user/tutorial/NUMPY_SUPPORT.md b/docs/user/tutorial/NUMPY_SUPPORT.md new file mode 100644 index 000000000..518b31baf --- /dev/null +++ b/docs/user/tutorial/NUMPY_SUPPORT.md @@ -0,0 +1,135 @@ +# Numpy Support + +In this section, we list the operations which are supported currently in the **Concrete Framework**. Please have a look to numpy [documentation](https://numpy.org/doc/stable/user/index.html) to know what these operations are about. + +## Unary operations + + + +List of supported unary functions: +- absolute +- arccos +- arccosh +- arcsin +- arcsinh +- arctan +- arctanh +- cbrt +- ceil +- cos +- cosh +- deg2rad +- degrees +- exp +- exp2 +- expm1 +- fabs +- floor +- isfinite +- isinf +- isnan +- log +- log10 +- log1p +- log2 +- logical_not +- negative +- positive +- rad2deg +- radians +- reciprocal +- rint +- sign +- signbit +- sin +- sinh +- spacing +- sqrt +- square +- tan +- tanh +- trunc + +## Binary operations + +List of supported binary functions if one of the two operators is a constant scalar: +- arctan2 +- bitwise_and +- bitwise_or +- bitwise_xor +- copysign +- equal +- float_power +- floor_divide +- fmax +- fmin +- fmod +- gcd +- greater +- greater_equal +- heaviside +- hypot +- lcm +- ldexp +- left_shift +- less +- less_equal +- logaddexp +- logaddexp2 +- logical_and +- logical_or +- logical_xor +- maximum +- minimum +- nextafter +- not_equal +- power +- remainder +- right_shift +- true_divide + + +## Indexing + +Indexing is described in [this section](../tutorial/INDEXING.md). + + +## Other machine-learning-related operators + +We support (sometimes, with limits) some other operators: + +- dot: one of the operators must be non-encrypted +- clip: the minimum and maximum values must be constant +- transpose +- ravel +- reshape: the shapes must be constant +- flatten +- matmul: one of the two matrices must be non-encrypted. Only 2D matrix multiplication is supported for now + +## Operators which are not numpy-restricted + +The framework also gives support for: + +- shifts, i.e., `x op y` for `op` in `[<<, >>, ]`: if one of `x` or `y` is a constant +- boolean test operations, i.e., `x op y` for `op` in `[<, <=, ==, !=, >, >=]`: if one of `x` or `y` is a constant +- boolean operators, i.e., `x op y` for `op` in `[&, ^, |]`: if one of `x` or `y` is a constant +- powers, i.e., `x ** y`: if one of `x` or `y` is a constant +- modulo, i.e., `x % y`: if one of `x` or `y` is a constant +- invert, i.e., `~x` +- true div, i.e., `x / y`: if one of `x` or `y` is a constant +- floor div, i.e., `x // y`: if one of `x` or `y` is a constant + +```{warning} +FIXME(Arthur): speak about `astype` +``` + +```{warning} +FIXME(Umut): speak about `shape` +``` + + + + + + + diff --git a/docs/user/tutorial/WORKING_WITH_FLOATING_POINTS.md b/docs/user/tutorial/WORKING_WITH_FLOATING_POINTS.md index 2ab456663..3ca0501a7 100644 --- a/docs/user/tutorial/WORKING_WITH_FLOATING_POINTS.md +++ b/docs/user/tutorial/WORKING_WITH_FLOATING_POINTS.md @@ -26,96 +26,8 @@ assert circuit.run(60) == f(60) print("All good!") ``` -## Supported operations +One can look to [numpy supported functions](NUMPY_SUPPORT.md) for information about possible float operations. -The following operations are supported in the latest release, and we'll add more operations in the upcoming releases. - - - -List of supported unary functions: -- absolute -- arccos -- arccosh -- arcsin -- arcsinh -- arctan -- arctanh -- cbrt -- ceil -- cos -- cosh -- deg2rad -- degrees -- exp -- exp2 -- expm1 -- fabs -- floor -- isfinite -- isinf -- isnan -- log -- log10 -- log1p -- log2 -- logical_not -- negative -- positive -- rad2deg -- radians -- reciprocal -- rint -- sign -- signbit -- sin -- sinh -- spacing -- sqrt -- square -- tan -- tanh -- trunc - -List of supported binary functions if one of the two operators is a constant scalar: -- arctan2 -- bitwise_and -- bitwise_or -- bitwise_xor -- copysign -- equal -- float_power -- floor_divide -- fmax -- fmin -- fmod -- gcd -- greater -- greater_equal -- heaviside -- hypot -- lcm -- ldexp -- left_shift -- less -- less_equal -- logaddexp -- logaddexp2 -- logical_and -- logical_or -- logical_xor -- maximum -- minimum -- nextafter -- not_equal -- power -- remainder -- right_shift -- true_divide - - -```{warning} -FIXME(Benoit): see what kind of other supported operations we could list here -``` ## Limitations diff --git a/script/doc_utils/gen_supported_ufuncs.py b/script/doc_utils/gen_supported_ufuncs.py index 6de3baeaa..a595b33bc 100644 --- a/script/doc_utils/gen_supported_ufuncs.py +++ b/script/doc_utils/gen_supported_ufuncs.py @@ -45,6 +45,9 @@ def main(file_to_update): newlines.extend(f"- {f}\n" for f in supported_unary_ufunc) newlines.append("\n") + newlines.append("## Binary operations\n") + newlines.append("\n") + newlines.append( "List of supported binary functions if one of the " "two operators is a constant scalar:\n"