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

added setup files in order to be able to install with pip #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ __pycache__/
*.gcno
test___*
docs/_build/*
local/*
local/*
*.egg-info/
3 changes: 2 additions & 1 deletion keras2c/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import argparse
import sys
from keras2c.keras2c_main import k2c
import tensorflow as tf


__author__ = "Rory Conlin"
Expand Down Expand Up @@ -37,7 +38,7 @@ def parse_args(args):


def main(args=sys.argv[1:]):

tf.compat.v1.disable_eager_execution()
args = parse_args(args)
if args.malloc:
malloc = True
Expand Down
1 change: 0 additions & 1 deletion keras2c/check_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from keras2c.weights2c import Weights2C
from keras2c.layer2c import Layers2C
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
5 changes: 2 additions & 3 deletions keras2c/keras2c_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import subprocess
import tensorflow.keras as keras
import tensorflow as tf
tf.compat.v1.disable_eager_execution()


__author__ = "Rory Conlin"
Expand All @@ -31,7 +30,7 @@
def model2c(model, function_name, malloc=False, verbose=True):
"""Generates C code for model

Writes main function definition to "function_name.c" and a public header
Writes main function definition to "function_name.c" and a public header
with declarations to "function_name.h"

Args:
Expand Down Expand Up @@ -196,7 +195,7 @@ def k2c(model, function_name, malloc=False, num_tests=10, verbose=True):
verbose (bool): whether to print progress

Raises:
ValueError: if model is not instance of keras.models.Model
ValueError: if model is not instance of keras.models.Model

Returns:
None
Expand Down
1 change: 0 additions & 1 deletion keras2c/layer2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# imports
from keras2c.io_parsing import layer_type, get_model_io_names, get_all_io_names, get_layer_io_names, flatten
import tensorflow as tf
tf.compat.v1.disable_eager_execution()


__author__ = "Rory Conlin"
Expand Down
3 changes: 1 addition & 2 deletions keras2c/make_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from keras2c.weights2c import Weights2C
import tensorflow as tf
import subprocess
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down Expand Up @@ -109,7 +108,7 @@ def make_test_suite(model, function_name, malloc_vars, num_tests=10, stateful=Fa
model_outputs[j] + '_test' + str(i+1)))
s = 'int main(){\n'
file.write(s)

s = ' float errors[' + str(num_tests*num_outputs) + '];\n'
s += ' size_t num_tests = ' + str(num_tests) + '; \n'
s += 'size_t num_outputs = ' + str(num_outputs) + '; \n'
Expand Down
4 changes: 2 additions & 2 deletions keras2c/weights2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from keras2c.io_parsing import layer_type, get_layer_io_names, get_model_io_names
from tensorflow.keras import backend as K
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

maxndim = 5


Expand Down Expand Up @@ -113,7 +113,7 @@ def write_weights(self, verbose=True):
(tuple): tuple containing

- **stack_vars** (*str*): code for variables allocated on the stack
- **malloc_vars** (*dict*): dictionary of name,value pairs for arrays to be
- **malloc_vars** (*dict*): dictionary of name,value pairs for arrays to be
allocated on the heap
- **static_vars** (*str*): code fora C struct containing static variables
(eg, states of a stateful RNN)
Expand Down
16 changes: 16 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[metadata]
name = keras2c
version = 0.0.1
description = Library for deploying keras neural networks in C99, using only standard libraries. It is designed to be as simple as possible for real time applications.
long_description = file: README.md

[options]
include_package_data = True
packages = find:
install_requires =
tensorflow
numpy

[options.entry_points]
console_scripts =
keras2c = keras2c.__main__:main
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import setuptools
setuptools.setup()
1 change: 0 additions & 1 deletion tests/test_advanced_activation_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
from test_core_layers import build_and_run
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
1 change: 0 additions & 1 deletion tests/test_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import time
import numpy as np
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
1 change: 0 additions & 1 deletion tests/test_convolution_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
from test_core_layers import build_and_run
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
11 changes: 5 additions & 6 deletions tests/test_core_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import time
import os
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand All @@ -22,7 +21,7 @@


CC = 'gcc'

seed = 100

def build_and_run(name, return_output=False):

Expand Down Expand Up @@ -153,7 +152,7 @@ class TestNormalization(unittest.TestCase):
def test_BatchNorm1(self):
inshp = (10, 11, 12)
axis = 3
init = keras.initializers.RandomUniform(minval=0.1, maxval=1.0)
init = keras.initializers.RandomUniform(minval=0.1, maxval=1.0, seed=seed)
a = keras.layers.Input(inshp)
b = keras.layers.BatchNormalization(axis=axis,
beta_initializer=init,
Expand All @@ -170,7 +169,7 @@ def test_BatchNorm1(self):
def test_BatchNorm2(self):
inshp = (10, 11, 12)
axis = 2
init = keras.initializers.RandomUniform(minval=0.1, maxval=1.0)
init = keras.initializers.RandomUniform(minval=0.1, maxval=1.0, seed=seed)
a = keras.layers.Input(inshp)
b = keras.layers.BatchNormalization(axis=axis,
beta_initializer=init,
Expand All @@ -187,7 +186,7 @@ def test_BatchNorm2(self):
def test_BatchNorm3(self):
inshp = (10, 11, 12, 13)
axis = 1
init = keras.initializers.RandomUniform(minval=0.1, maxval=1.0)
init = keras.initializers.RandomUniform(minval=0.1, maxval=1.0, seed=seed)
a = keras.layers.Input(inshp)
b = keras.layers.BatchNormalization(axis=axis,
beta_initializer=init,
Expand All @@ -204,7 +203,7 @@ def test_BatchNorm3(self):
def test_BatchNorm4(self):
inshp = (10, 11, 12)
axis = 2
init = keras.initializers.RandomUniform(minval=0.1, maxval=2.0)
init = keras.initializers.RandomUniform(minval=0.1, maxval=2.0, seed=seed)
a = keras.layers.Input(inshp)
b = keras.layers.BatchNormalization(axis=axis,
beta_initializer=init,
Expand Down
1 change: 0 additions & 1 deletion tests/test_malloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
from test_core_layers import build_and_run
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
1 change: 0 additions & 1 deletion tests/test_merge_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
from test_core_layers import build_and_run
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
1 change: 0 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import os
from test_core_layers import build_and_run
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
1 change: 0 additions & 1 deletion tests/test_pooling_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
from test_core_layers import build_and_run
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down
1 change: 0 additions & 1 deletion tests/test_recurrent_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import os
from test_core_layers import build_and_run
import tensorflow as tf
tf.compat.v1.disable_eager_execution()

__author__ = "Rory Conlin"
__copyright__ = "Copyright 2020, Rory Conlin"
Expand Down