modifed Paddle.swig to specially handle UnsupportError only

avx_docs
wangyang59 9 years ago
parent b207535198
commit 4c86285a99

@ -53,7 +53,8 @@ Matrix* Matrix::createDense(const std::vector<float>& data, size_t height,
} }
Matrix* Matrix::createDenseFromNumpy(float* data, int dim1, int dim2, Matrix* Matrix::createDenseFromNumpy(float* data, int dim1, int dim2,
bool copy, bool useGpu) { bool copy, bool useGpu)
throw (UnsupportError) {
if (useGpu) { if (useGpu) {
/// Gpu mode only supports copy=True /// Gpu mode only supports copy=True
if (!copy) { if (!copy) {

@ -6,17 +6,10 @@
%} %}
%include "exception.i" %include "exception.i"
%exception{ %typemap(throws) UnsupportError %{
try{ SWIG_exception(SWIG_RuntimeError, $1.what());
$action SWIG_fail;
} %}
catch(UnsupportError &ex ){
SWIG_exception(SWIG_RuntimeError, ex.what());
}
catch( ... ){
SWIG_fail;
}
}
%include "std_vector.i" %include "std_vector.i"
%include "std_pair.i" %include "std_pair.i"

@ -139,7 +139,8 @@ public:
static Matrix* createDenseFromNumpy(float* data, int dim1, int dim2, static Matrix* createDenseFromNumpy(float* data, int dim1, int dim2,
bool copy = true, bool copy = true,
bool useGpu = isUsingGpu()); bool useGpu = isUsingGpu())
throw (UnsupportError);
/** /**
* Create Cpu Dense Matrix from numpy matrix, dtype=float32 * Create Cpu Dense Matrix from numpy matrix, dtype=float32
@ -248,7 +249,8 @@ public:
bool useGpu = isUsingGpu()); bool useGpu = isUsingGpu());
static Vector* createVectorFromNumpy(float* data, int dim, bool copy = true, static Vector* createVectorFromNumpy(float* data, int dim, bool copy = true,
bool useGpu = isUsingGpu()); bool useGpu = isUsingGpu())
throw (UnsupportError);
/** /**
* Create Cpu Vector from numpy array, which dtype=float32 * Create Cpu Vector from numpy array, which dtype=float32
* *
@ -311,7 +313,8 @@ public:
bool useGpu = isUsingGpu()); bool useGpu = isUsingGpu());
static IVector* createVectorFromNumpy(int* data, int dim, bool copy = true, static IVector* createVectorFromNumpy(int* data, int dim, bool copy = true,
bool useGpu = isUsingGpu()); bool useGpu = isUsingGpu())
throw (UnsupportError);
/** /**
* Create Cpu IVector from numpy array, which dtype=int32 * Create Cpu IVector from numpy array, which dtype=int32

@ -40,7 +40,7 @@ IVector* IVector::create(const std::vector<int>& data, bool useGpu) {
} }
IVector* IVector::createVectorFromNumpy(int* data, int dim, bool copy, IVector* IVector::createVectorFromNumpy(int* data, int dim, bool copy,
bool useGpu) { bool useGpu) throw (UnsupportError){
if (useGpu) { if (useGpu) {
/// if use gpu only copy=true is supported /// if use gpu only copy=true is supported
if (!copy) { if (!copy) {
@ -202,7 +202,7 @@ Vector* Vector::createByPaddleVectorPtr(void* ptr) {
} }
Vector* Vector::createVectorFromNumpy(float* data, int dim, bool copy, Vector* Vector::createVectorFromNumpy(float* data, int dim, bool copy,
bool useGpu) { bool useGpu) throw (UnsupportError){
if (useGpu) { if (useGpu) {
/// if use gpu only copy=True is supported /// if use gpu only copy=True is supported
if (!copy) { if (!copy) {

Loading…
Cancel
Save