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

Fix 3rd #70

Merged
merged 18 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 14 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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ dist/
Makefile
!docs/Makefile
version.py
setup.py
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
url = https://github.com/gabime/spdlog.git
[submodule "3rd/eigen3"]
path = 3rd/eigen3
url = https://github.com/eigenteam/eigen-git-mirror.git
url = https://gitlab.com/libeigen/eigen.git
24 changes: 0 additions & 24 deletions .project.info

This file was deleted.

2 changes: 1 addition & 1 deletion 3rd/eigen3
Submodule eigen3 updated from cf794d to 314739
9 changes: 9 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include install/cuda_setup.py
include 3rd/json11/json11.hpp
include 3rd/json11/json11.cpp
recursive-include 3rd/eigen3/Eigen/ *
recursive-include 3rd/eigen3/unsupported/Eigen/ *
recursive-include 3rd/spdlog/include/spdlog/ *
recursive-include buffalo/ *.py *.pyx *.hpp
recursive-include include/ *.hpp
recursive-include lib/ *.cc *.cu
13 changes: 4 additions & 9 deletions buffalo/algo/_als.pyx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython

cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimport bool
from libcpp.pair cimport pair
from libcpp.string cimport string

import numpy as np

cimport numpy as np
np.import_array()


cdef extern from "buffalo/algo_impl/als/als.hpp" namespace "als":
cdef cppclass CALS:
void release() nogil except +
bool init(string) nogil except +
bint init(string) nogil except +
void initialize_model(float*, int,
float*, int) nogil except +
void precompute(int) nogil except +
Expand Down Expand Up @@ -51,8 +48,6 @@ cdef class CyALS:
def precompute(self, axis):
self.obj.precompute(axis)

@cython.boundscheck(False)
@cython.wraparound(False)
def partial_update(self,
int start_x,
int next_x,
Expand Down
13 changes: 4 additions & 9 deletions buffalo/algo/_bpr.pyx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython

cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimport bool
from libcpp.string cimport string

import numpy as np

cimport numpy as np
np.import_array()


cdef extern from "buffalo/algo_impl/bpr/bpr.hpp" namespace "bpr":
cdef cppclass CBPRMF:
void release() nogil except +
bool init(string) nogil except +
bint init(string) nogil except +
void initialize_model(float*, int32_t,
float*, int32_t,
float*,
Expand Down Expand Up @@ -66,8 +63,6 @@ cdef class CyBPRMF:
int cum_table_size):
self.obj.set_cumulative_table(&cum_table[0], cum_table_size)

@cython.boundscheck(False)
@cython.wraparound(False)
def add_jobs(self,
int start_x,
int next_x,
Expand Down
18 changes: 4 additions & 14 deletions buffalo/algo/_cfr.pyx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython

cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimport bool as bool_t
from libcpp.string cimport string
from libcpp.vector cimport vector

import numpy as np

cimport numpy as np
np.import_array()


cdef extern from "buffalo/algo_impl/cfr/cfr.hpp" namespace "cfr":
cdef cppclass CCFR:
bool_t init(string) nogil except +
bint init(string) nogil except +
void set_embedding(float*, int, string) nogil except +
void precompute(string) nogil except +
double partial_update_user(int, int,
Expand Down Expand Up @@ -46,17 +42,13 @@ cdef class CyCFR:
np.ndarray[np.float32_t, ndim=2] F, obj_type):
self.obj.set_embedding(&F[0, 0], F.shape[0], obj_type)

@cython.boundscheck(False)
@cython.wraparound(False)
def partial_update_user(self, int start_x, int next_x,
np.ndarray[np.int64_t, ndim=1] indptrs,
np.ndarray[np.int32_t, ndim=1] keys,
np.ndarray[np.float32_t, ndim=1] vals):
return self.obj.partial_update_user(start_x, next_x,
&indptrs[0], &keys[0], &vals[0])

@cython.boundscheck(False)
@cython.wraparound(False)
def partial_update_item(self, int start_x, int next_x,
np.ndarray[np.int64_t, ndim=1] indptrs_u,
np.ndarray[np.int32_t, ndim=1] keys_u,
Expand All @@ -68,8 +60,6 @@ cdef class CyCFR:
&indptrs_u[0], &keys_u[0], &vals_u[0],
&indptrs_c[0], &keys_c[0], &vals_c[0])

@cython.boundscheck(False)
@cython.wraparound(False)
def partial_update_context(self, int start_x, int next_x,
np.ndarray[np.int64_t, ndim=1] indptrs,
np.ndarray[np.int32_t, ndim=1] keys,
Expand Down
11 changes: 4 additions & 7 deletions buffalo/algo/_plsi.pyx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython
import numpy as np

cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimport bool as bool_t
from libcpp.string cimport string

np.import_array()


cdef extern from "buffalo/algo_impl/plsi/plsi.hpp" namespace "plsi":
cdef cppclass CPLSI:
bool_t init(string) nogil except +
bint init(string) nogil except +
void release() nogil except +
void swap() nogil except +
void reset() nogil except +
Expand Down Expand Up @@ -51,8 +50,6 @@ cdef class CyPLSI:
def normalize(self, alpha1, alpha2):
self.obj.normalize(alpha1, alpha2)

@cython.boundscheck(False)
@cython.wraparound(False)
def partial_update(self, int start_x, int next_x,
np.ndarray[np.int64_t, ndim=1] indptr,
np.ndarray[np.int32_t, ndim=1] keys,
Expand Down
13 changes: 4 additions & 9 deletions buffalo/algo/_w2v.pyx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython

cimport numpy as np
from libc.stdint cimport int32_t, int64_t, uint32_t
from libcpp cimport bool
from libcpp.string cimport string

import numpy as np

cimport numpy as np
np.import_array()


cdef extern from "buffalo/algo_impl/w2v/w2v.hpp" namespace "w2v":
cdef cppclass CW2V:
void release() nogil except +
bool init(string) nogil except +
bint init(string) nogil except +
void initialize_model(float*, int32_t,
int32_t*,
uint32_t*,
Expand Down Expand Up @@ -58,8 +55,6 @@ cdef class CyW2V:
def launch_workers(self):
self.obj.launch_workers()

@cython.boundscheck(False)
@cython.wraparound(False)
def add_jobs(self,
int start_x,
int next_x,
Expand Down
13 changes: 4 additions & 9 deletions buffalo/algo/_warp.pyx
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython

cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimport bool
from libcpp.string cimport string

import numpy as np

cimport numpy as np
np.import_array()


cdef extern from "buffalo/algo_impl/warp/warp.hpp" namespace "warp":
cdef cppclass CWARP:
void release() nogil except +
bool init(string) nogil except +
bint init(string) nogil except +
void initialize_model(float*, int32_t,
float*, int32_t,
float*,
Expand Down Expand Up @@ -66,8 +63,6 @@ cdef class CyWARP:
def launch_workers(self):
self.obj.launch_workers()

@cython.boundscheck(False)
@cython.wraparound(False)
def add_jobs(self,
int start_x,
int next_x,
Expand Down
15 changes: 5 additions & 10 deletions buffalo/algo/cuda/_als.pyx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython

cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimport bool
from libcpp.pair cimport pair
from libcpp.string cimport string

import numpy as np

cimport numpy as np
np.import_array()


cdef extern from "buffalo/cuda/als/als.hpp" namespace "cuda_als":
cdef cppclass CuALS:
CuALS() nogil except +
bool init(string) nogil except +
bint init(string) nogil except +
void set_placeholder(int64_t* lindptr, int64_t* rindptr, size_t batch_size)
void initialize_model(float*, int,
float*, int) nogil except +
Expand Down Expand Up @@ -46,7 +43,7 @@ cdef class CyALS:

def set_placeholder(self, np.ndarray[np.int64_t, ndim=1] lindptr,
np.ndarray[np.int64_t, ndim=1] rindptr,
batch_size):
size_t batch_size):
self.obj.set_placeholder(&lindptr[0], &rindptr[0], batch_size)

def precompute(self, axis):
Expand All @@ -55,8 +52,6 @@ cdef class CyALS:
def get_vdim(self):
return self.obj.get_vdim()

@cython.boundscheck(False)
@cython.wraparound(False)
def partial_update(self,
int start_x,
int next_x,
Expand Down
19 changes: 6 additions & 13 deletions buffalo/algo/cuda/_bpr.pyx
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
# cython: experimental_cpp_class_def=True, language_level=3
# cython: language_level=3, boundscheck=False, wraparound=False
# distutils: language=c++
import cython

cimport numpy as np
from libc.stdint cimport int32_t, int64_t
from libcpp cimport bool
from libcpp.pair cimport pair
from libcpp.string cimport string

import numpy as np

cimport numpy as np
np.import_array()


cdef extern from "buffalo/cuda/bpr/bpr.hpp" namespace "cuda_bpr":
cdef cppclass CuBPR:
CuBPR() nogil except +
bool init(string) nogil except +
bint init(string) nogil except +
void set_placeholder(int64_t* indptr, size_t batch_size) nogil except +
void set_cumulative_table(int64_t*) nogil except +
void initialize_model(float*, int,
float*, float*, int, int64_t, bool) nogil except +
float*, float*, int, int64_t, bint) nogil except +
pair[double, double] partial_update(int, int,
int64_t*, int32_t*) nogil except +
double compute_loss(int, int32_t*, int32_t*, int32_t*) nogil except +
int get_vdim() nogil except +
void synchronize(bool)
void synchronize(bint)


cdef class CyBPR:
Expand Down Expand Up @@ -66,8 +63,6 @@ cdef class CyBPR:
def wait_until_done(self):
return

@cython.boundscheck(False)
@cython.wraparound(False)
def add_jobs(self,
int start_x,
int next_x,
Expand All @@ -78,8 +73,6 @@ cdef class CyBPR:
&indptr[0],
&keys[0])

@cython.boundscheck(False)
@cython.wraparound(False)
def compute_loss(self,
np.ndarray[np.int32_t, ndim=1] user,
np.ndarray[np.int32_t, ndim=1] pos,
Expand Down
Loading
Loading