diff --git a/README.md b/README.md index 62b4d51..de9aba1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Copapy -Copapy is a Python framework for deterministic, low-latency realtime computation, targeting hardware applications - for example in the fields of robotics, aerospace, embedded systems and control systems in general. +Copapy is a Python framework for deterministic, low-latency realtime computation with automatic differentiation support, targeting hardware applications - for example in the fields of robotics, aerospace, embedded systems and control systems in general. GPU frameworks like PyTorch, JAX and TensorFlow jump-started the development in the field of AI. With the right balance of flexibility and performance, they allow for fast iteration of new ideas while still being performant enough to test or even use them in production. @@ -12,7 +12,7 @@ The main features can be summarized as: - Fast to write & easy to read - Memory and type safety with a minimal set of runtime errors - Deterministic execution -- Autograd for efficient realtime optimization +- Automatic differentiation for efficient realtime optimization (reverse-mode) - Optimized machine code for x86_64, AArch64 and ARMv7 - Highly portable to new architectures - Small Python package with minimal dependencies and no cross-compile toolchain required diff --git a/src/copapy/__init__.py b/src/copapy/__init__.py index 6bb1d59..4297d2d 100644 --- a/src/copapy/__init__.py +++ b/src/copapy/__init__.py @@ -1,3 +1,38 @@ +""" +Copapy is a Python framework for deterministic, low-latency +realtime computation with automatic differentiation, targeting +hardware applications - for example in the fields of robotics, +aerospace, embedded systems and control systems in general. + +Main features: +- Automatic differentiation (reverse-mode) +- Generates optimized machine code +- Highly portable to new architectures +- Small Python package with minimal dependencies + +Example usage: + >>> import copapy as cp + + >>> # Define variables + >>> a = cp.value(0.25) + >>> b = cp.value(0.87) + + >>> # Define computations + >>> c = a + b * 2.0 + >>> d = c ** 2 + cp.sin(a) + >>> e = cp.sqrt(b) + + >>> # Create a target (default is local), compile and run + >>> tg = cp.Target() + >>> tg.compile(c, d, e) + >>> tg.run() + + >>> # Read the results + >>> print("Result c:", tg.read_value(c)) + >>> print("Result d:", tg.read_value(d)) + >>> print("Result e:", tg.read_value(e)) +""" + from ._target import Target, jit from ._basic_types import NumLike, value, generic_sdb, iif from ._vectors import vector, distance, scalar_projection, angle_between, rotate_vector, vector_projection diff --git a/src/copapy/_autograd.py b/src/copapy/_autograd.py index b09da2d..a3ff594 100644 --- a/src/copapy/_autograd.py +++ b/src/copapy/_autograd.py @@ -15,7 +15,8 @@ def grad(x: Any, y: Sequence[value[Any]]) -> list[unifloat]: ... def grad(x: Any, y: matrix[Any]) -> matrix[float]: ... def grad(x: Any, y: value[Any] | Sequence[value[Any]] | vector[Any] | matrix[Any]) -> Any: """Returns the partial derivative dx/dy where x needs to be a scalar - and y might be a scalar, a list of scalars, a vector or matrix. + and y might be a scalar, a list of scalars, a vector or matrix. It + uses automatic differentiation in reverse-mode. Arguments: x: Value to return derivative of diff --git a/src/copapy/backend.py b/src/copapy/backend.py index f494d1d..4ff6109 100644 --- a/src/copapy/backend.py +++ b/src/copapy/backend.py @@ -1,3 +1,8 @@ +""" +Backend module for Copapy: contains internal data types +and give access to compiler internals and debugging tools. +""" + from ._target import add_read_command from ._basic_types import Net, Op, Node, CPConstant, Write, stencil_db_from_package from ._compiler import compile_to_dag, \