Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to jax #31

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ You should then be able to run the examples and tutorials in the examples folder
.. _PyPI: https://pypi.org/project/SiPANN/


JAX support
===========

SiPANN provides optional support for [JAX](https://github.com/google/jax). You need to have JAX installed in order to let SiPANN use `jax.numpy`(which is faster) instead of `numpy`. For installation instructions, see the [JAX documentation](https://github.com/google/jax#installation).


References
==========

Expand Down
5 changes: 4 additions & 1 deletion SiPANN/comp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from abc import ABC, abstractmethod

import gdspy
import numpy as np
try:
import jax.numpy as np
except ImportError:
import numpy as np
import pkg_resources
import scipy.integrate as integrate
import scipy.special as special
Expand Down
5 changes: 4 additions & 1 deletion SiPANN/import_nn.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pickle
from itertools import combinations_with_replacement as comb_w_r

import numpy as np
try:
import jax.numpy as np
except ImportError:
import numpy as np
import tensorflow as tf


Expand Down
5 changes: 4 additions & 1 deletion SiPANN/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
# ---------------------------------------------------------------------------- #
# Import libraries
# ---------------------------------------------------------------------------- #
import numpy as np
try:
import jax.numpy as np
except ImportError:
import numpy as np
import pkg_resources
import skrf as rf
from scipy.interpolate import UnivariateSpline
Expand Down
5 changes: 4 additions & 1 deletion SiPANN/scee.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from abc import ABC, abstractmethod

import gdspy
import numpy as np
try:
import jax.numpy as np
except ImportError:
import numpy as np
import pkg_resources
from scipy import special
from scipy.integrate import quad
Expand Down
5 changes: 4 additions & 1 deletion SiPANN/scee_int.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import numpy as np
try:
import jax.numpy as np
except ImportError:
import numpy as np
from simphony import Model
from simphony.layout import Circuit
from simphony.pins import Pin, PinList
Expand Down
5 changes: 4 additions & 1 deletion SiPANN/scee_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import os

import matplotlib.pyplot as plt
import numpy as np
try:
import jax.numpy as np
except ImportError:
import numpy as np
from numba import njit, vectorize
from numba.extending import get_cython_function_address
from scipy import special
Expand Down