提交 4c86285a 编写于 作者: W wangyang59

modifed Paddle.swig to specially handle UnsupportError only

上级 b2075351
...@@ -53,7 +53,8 @@ Matrix* Matrix::createDense(const std::vector<float>& data, size_t height, ...@@ -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 @@ ...@@ -6,17 +6,10 @@
%} %}
%include "exception.i" %include "exception.i"
%exception{ %typemap(throws) UnsupportError %{
try{ SWIG_exception(SWIG_RuntimeError, $1.what());
$action
}
catch(UnsupportError &ex ){
SWIG_exception(SWIG_RuntimeError, ex.what());
}
catch( ... ){
SWIG_fail; SWIG_fail;
} %}
}
%include "std_vector.i" %include "std_vector.i"
%include "std_pair.i" %include "std_pair.i"
......
...@@ -139,7 +139,8 @@ public: ...@@ -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: ...@@ -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: ...@@ -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) { ...@@ -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) { ...@@ -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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册