Skip to content

Commit

Permalink
Windows support
Browse files Browse the repository at this point in the history
  • Loading branch information
olegranmo committed Jan 11, 2023
1 parent 25365a6 commit 4d0fa58
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='tmu',
version='0.7.0',
version='0.7.1',
url='https://github.com/cair/tmu/',
author='Ole-Christoffer Granmo',
author_email='[email protected]',
Expand Down
24 changes: 13 additions & 11 deletions tmu/tools_extension_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
# https://arxiv.org/abs/1905.09688

from cffi import FFI
import pathlib
current_dir = pathlib.Path(__file__).parent

ffibuilder = FFI()

ffibuilder.cdef("""
void tmu_produce_autoencoder_examples(unsigned int *active_output, int number_of_active_outputs, unsigned int *indptr_row, unsigned int *indices_row, int number_of_rows, unsigned int *indptr_col, unsigned int *indices_col, int number_of_cols, unsigned int *encoded_X, unsigned int *Y, int accumulation, int append_negated);
void tmu_encode(unsigned int *X, unsigned int *encoded_X, int number_of_examples, int dim_x, int dim_y, int dim_z, int patch_dim_x, int patch_dim_y, int append_negated, int class_features);
""")
with current_dir.joinpath("Tools.h").open("r") as f:
ffibuilder .cdef(f.read())

ffibuilder.set_source("tmu._tools", # name of the output C extension
"""
#include "./tmu/Tools.h"
""",
include_dirs=['.'],
sources=['./tmu/Tools.c'])
with current_dir.joinpath("Tools.c").open("r") as f:
ffibuilder .set_source(
"tmu._tools",
f.read(),
include_dirs=[current_dir.absolute()],
source_extension=".c",
)

if __name__ == "__main__":
ffibuilder.compile(verbose=True)
ffibuilder .compile(verbose=True)
24 changes: 13 additions & 11 deletions tmu/weight_bank_extension_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
# https://arxiv.org/abs/1905.09688

from cffi import FFI
import pathlib
current_dir = pathlib.Path(__file__).parent

ffibuilder = FFI()

ffibuilder.cdef("""
void wb_increment(int *clause_weights, int number_of_clauses, unsigned int *clause_output, float update_p, unsigned int *clause_active, unsigned int positive_weights);
void wb_decrement(int *clause_weights, int number_of_clauses, unsigned int *clause_output, float update_p, unsigned int *clause_active, unsigned int negative_weights);
""")
with current_dir.joinpath("WeightBank.h").open("r") as f:
ffibuilder.cdef(f.read())

ffibuilder.set_source("tmu._wb", # name of the output C extension
"""
#include "./tmu/WeightBank.h"
""",
include_dirs=['.'],
sources=['./tmu/WeightBank.c']) # on Unix, link with the math library
with current_dir.joinpath("WeightBank.c").open("r") as f:
ffibuilder.set_source(
"tmu._wb",
f.read(),
include_dirs=[current_dir.absolute()],
source_extension=".c",
)

if __name__ == "__main__":
ffibuilder.compile(verbose=True)
ffibuilder.compile(verbose=True)

0 comments on commit 4d0fa58

Please sign in to comment.