提交 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,
}
Matrix* Matrix::createDenseFromNumpy(float* data, int dim1, int dim2,
bool copy, bool useGpu) {
bool copy, bool useGpu)
throw (UnsupportError) {
if (useGpu) {
/// Gpu mode only supports copy=True
if (!copy) {
......
......@@ -6,17 +6,10 @@
%}
%include "exception.i"
%exception{
try{
$action
}
catch(UnsupportError &ex ){
SWIG_exception(SWIG_RuntimeError, ex.what());
}
catch( ... ){
%typemap(throws) UnsupportError %{
SWIG_exception(SWIG_RuntimeError, $1.what());
SWIG_fail;
}
}
%}
%include "std_vector.i"
%include "std_pair.i"
......
......@@ -139,7 +139,8 @@ public:
static Matrix* createDenseFromNumpy(float* data, int dim1, int dim2,
bool copy = true,
bool useGpu = isUsingGpu());
bool useGpu = isUsingGpu())
throw (UnsupportError);
/**
* Create Cpu Dense Matrix from numpy matrix, dtype=float32
......@@ -248,7 +249,8 @@ public:
bool useGpu = isUsingGpu());
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
*
......@@ -311,7 +313,8 @@ public:
bool useGpu = isUsingGpu());
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
......
......@@ -40,7 +40,7 @@ IVector* IVector::create(const std::vector<int>& data, bool useGpu) {
}
IVector* IVector::createVectorFromNumpy(int* data, int dim, bool copy,
bool useGpu) {
bool useGpu) throw (UnsupportError){
if (useGpu) {
/// if use gpu only copy=true is supported
if (!copy) {
......@@ -202,7 +202,7 @@ Vector* Vector::createByPaddleVectorPtr(void* ptr) {
}
Vector* Vector::createVectorFromNumpy(float* data, int dim, bool copy,
bool useGpu) {
bool useGpu) throw (UnsupportError){
if (useGpu) {
/// if use gpu only copy=True is supported
if (!copy) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册