Metadata-Version: 2.4
Name: hyjax
Version: 0.1.0
Summary: Hy bindings for JAX
Project-URL: Homepage, https://github.com/mlegls/hyjax
Project-URL: Bug Tracker, https://github.com/mlegls/hyjax/issues
Author-email: 疒奀 <yz@mmon.co>
License: MIT License
        
        Copyright (c) 2022 疒奀
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: hy>=1.0.0
Requires-Dist: hyrule>=1.0.0
Requires-Dist: jax>=0.4.30
Provides-Extra: dev
Description-Content-Type: text/markdown

# Hyjax

`pip install hyjax`

Hyjax is [Hy](https://github.com/hylang/hy) bindings for [JAX](https://github.com/google/jax). 


> When walking about the countryside of Italy, the people will not hesitate to tell you that JAX has [“una anima di pura programmazione funzionale”](https://www.sscardapane.it/iaml-backup/jax-intro/).
> –– <cite>[🔪 JAX - The Sharp Bits 🔪](https://jax.readthedocs.io/en/latest/notebooks/Common_Gotchas_in_JAX.html?highlight=pure%20functional)</cite>

> “As one would expect from its goals, artificial intelligence research generates many significant programming problems. In other programming cultures this spate of problems spawns new languages. ... We toast the Lisp programmer who pens his thoughts within nests of parentheses.”
> -- <cite>Alan J. Perlis</cite>

> You now know enough to be dangerous with Hy. You may now smile villainously and sneak off to your Hydeaway to do unspeakable things.
> –– <cite>[Hy Tutorial](https://docs.hylang.org/en/stable/tutorial.html?highlight=hydeaway#next-steps)</cite>

The goals are
1. the name pun was funny
2. let fully JIT-compiled JAX code be written in idiomatic Lisp

Some examples loosely inspired by the [JAX Quickstart](https://jax.readthedocs.io/en/latest/notebooks/quickstart.html) tutorials are in `src/experiments.hy`. The [Hy](https://docs.hylang.org/en/stable/index.html) and [JAX](https://jax.readthedocs.io/en/latest/) docs might also be helpful.

## Features
- [x] `(mapv f vec)` as `vmap(f)(vec)`
- [x] `(if/ja pred then else)` as `lax.cond`
- [x] `(defn/j f [args] body)` as `@jit def f(args): ...`
  - [x] identical syntax to Hy's [`defn`](https://docs.hylang.org/en/stable/api.html#defn); supports other decorators, annotations, variadic & keyword args
- [x] `(if pred then else)` inside `defn/j` as `lax.cond`
  - [x] works with any macros that compile to `if`, such as `cond`
- [ ] binding for `lax.while_loop`
- [ ] binding for `lax.fori_loop`
