Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SeetaResearch
/
Dragon
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d64a3943
authored
Aug 11, 2017
by
Ting PAN
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the potential crash of DragonBoard
1 parent
53d5742d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
28 deletions
Dragon/modules/python/dragon.h
Dragon/python/dragon/core/tensor.py
Dragon/python/dragon/tools/board/app.py
Dragon/python/requirements.txt
README.md
Dragon/modules/python/dragon.h
View file @
d64a394
...
@@ -57,8 +57,8 @@ std::string MakeString(const Args&... args) {
...
@@ -57,8 +57,8 @@ std::string MakeString(const Args&... args) {
return
std
::
string
(
ss
.
str
());
return
std
::
string
(
ss
.
str
());
}
}
inline
void
PrErr_SetString
(
PyObject
*
type
,
const
std
::
string
&
str
)
{
inline
void
PrErr_SetString
(
PyObject
*
type
,
const
std
::
string
&
str
)
{
PyErr_SetString
(
type
,
str
.
c_str
());
PyErr_SetString
(
type
,
str
.
c_str
());
}
}
class
TensorFetcherBase
{
class
TensorFetcherBase
{
...
@@ -70,8 +70,8 @@ class TensorFetcherBase {
...
@@ -70,8 +70,8 @@ class TensorFetcherBase {
class
TensorFeederBase
{
class
TensorFeederBase
{
public
:
public
:
virtual
~
TensorFeederBase
()
{}
virtual
~
TensorFeederBase
()
{}
virtual
PyObject
*
Feed
(
const
DeviceOption
&
option
,
virtual
PyObject
*
Feed
(
const
DeviceOption
&
option
,
PyArrayObject
*
array
,
PyArrayObject
*
array
,
Tensor
*
tensor
)
=
0
;
Tensor
*
tensor
)
=
0
;
};
};
...
@@ -79,8 +79,8 @@ DECLARE_TYPED_REGISTRY(TensorFetcherRegistry, TypeId, TensorFetcherBase);
...
@@ -79,8 +79,8 @@ DECLARE_TYPED_REGISTRY(TensorFetcherRegistry, TypeId, TensorFetcherBase);
#define REGISTER_TENSOR_FETCHER(type, ...) \
#define REGISTER_TENSOR_FETCHER(type, ...) \
REGISTER_TYPED_CLASS(TensorFetcherRegistry, type, __VA_ARGS__)
REGISTER_TYPED_CLASS(TensorFetcherRegistry, type, __VA_ARGS__)
inline
TensorFetcherBase
*
createFetcher
(
TypeId
type
)
{
inline
TensorFetcherBase
*
CreateFetcher
(
TypeId
type
)
{
return
TensorFetcherRegistry
()
->
Create
(
type
);
return
TensorFetcherRegistry
()
->
Create
(
type
);
}
}
DECLARE_TYPED_REGISTRY
(
TensorFeederRegistry
,
TypeId
,
TensorFeederBase
);
DECLARE_TYPED_REGISTRY
(
TensorFeederRegistry
,
TypeId
,
TensorFeederBase
);
...
@@ -107,11 +107,11 @@ class NumpyFetcher : public TensorFetcherBase {
...
@@ -107,11 +107,11 @@ class NumpyFetcher : public TensorFetcherBase {
// copy the tensor data to the numpy array
// copy the tensor data to the numpy array
if
(
tensor
.
memory_state
()
==
MixedMemory
::
STATE_AT_CUDA
)
{
if
(
tensor
.
memory_state
()
==
MixedMemory
::
STATE_AT_CUDA
)
{
CUDAContext
::
Memcpy
<
CPUContext
,
CUDAContext
>
(
tensor
.
nbytes
(),
CUDAContext
::
Memcpy
<
CPUContext
,
CUDAContext
>
(
tensor
.
nbytes
(),
PyArray_DATA
(
reinterpret_cast
<
PyArrayObject
*>
(
array
)),
PyArray_DATA
(
reinterpret_cast
<
PyArrayObject
*>
(
array
)),
tensor
.
raw_data
<
CUDAContext
>
());
tensor
.
raw_data
<
CUDAContext
>
());
}
else
{
}
else
{
CPUContext
::
Memcpy
<
CPUContext
,
CPUContext
>
(
tensor
.
nbytes
(),
CPUContext
::
Memcpy
<
CPUContext
,
CPUContext
>
(
tensor
.
nbytes
(),
PyArray_DATA
(
reinterpret_cast
<
PyArrayObject
*>
(
array
)),
PyArray_DATA
(
reinterpret_cast
<
PyArrayObject
*>
(
array
)),
tensor
.
raw_data
<
CPUContext
>
());
tensor
.
raw_data
<
CPUContext
>
());
}
}
return
array
;
return
array
;
...
@@ -128,8 +128,8 @@ class StringFetcher : public TensorFetcherBase {
...
@@ -128,8 +128,8 @@ class StringFetcher : public TensorFetcherBase {
class
NumpyFeeder
:
public
TensorFeederBase
{
class
NumpyFeeder
:
public
TensorFeederBase
{
public
:
public
:
PyObject
*
Feed
(
const
DeviceOption
&
option
,
PyObject
*
Feed
(
const
DeviceOption
&
option
,
PyArrayObject
*
original_array
,
PyArrayObject
*
original_array
,
Tensor
*
tensor
)
override
{
Tensor
*
tensor
)
override
{
PyArrayObject
*
array
=
PyArray_GETCONTIGUOUS
(
original_array
);
PyArrayObject
*
array
=
PyArray_GETCONTIGUOUS
(
original_array
);
const
TypeMeta
&
meta
=
NumpyTypeToDragon
(
PyArray_TYPE
(
array
));
const
TypeMeta
&
meta
=
NumpyTypeToDragon
(
PyArray_TYPE
(
array
));
...
@@ -150,14 +150,14 @@ class NumpyFeeder : public TensorFeederBase {
...
@@ -150,14 +150,14 @@ class NumpyFeeder : public TensorFeederBase {
#ifdef WITH_CUDA
#ifdef WITH_CUDA
CUDAContext
context
(
option
);
CUDAContext
context
(
option
);
context
.
SwitchToDevice
();
context
.
SwitchToDevice
();
context
.
Memcpy
<
CUDAContext
,
CPUContext
>
(
tensor
->
nbytes
(),
context
.
Memcpy
<
CUDAContext
,
CPUContext
>
(
tensor
->
nbytes
(),
tensor
->
raw_mutable_data
<
CUDAContext
>
(),
tensor
->
raw_mutable_data
<
CUDAContext
>
(),
static_cast
<
void
*>
(
PyArray_DATA
(
array
)));
static_cast
<
void
*>
(
PyArray_DATA
(
array
)));
#else
#else
LOG
(
FATAL
)
<<
"CUDA is not compilied."
;
LOG
(
FATAL
)
<<
"CUDA is not compilied."
;
#endif
#endif
}
else
{
}
else
{
CPUContext
::
Memcpy
<
CPUContext
,
CPUContext
>
(
tensor
->
nbytes
(),
CPUContext
::
Memcpy
<
CPUContext
,
CPUContext
>
(
tensor
->
nbytes
(),
tensor
->
raw_mutable_data
<
CPUContext
>
(),
tensor
->
raw_mutable_data
<
CPUContext
>
(),
static_cast
<
void
*>
(
PyArray_DATA
(
array
)));
static_cast
<
void
*>
(
PyArray_DATA
(
array
)));
}
}
...
@@ -166,4 +166,4 @@ class NumpyFeeder : public TensorFeederBase {
...
@@ -166,4 +166,4 @@ class NumpyFeeder : public TensorFeederBase {
}
}
};
};
#endif // DRAGON_MODULES_PYTHON_DRAGON_H_
#endif // DRAGON_MODULES_PYTHON_DRAGON_H_
\ No newline at end of file
Dragon/python/dragon/core/tensor.py
View file @
d64a394
...
@@ -23,7 +23,7 @@ class Tensor(object):
...
@@ -23,7 +23,7 @@ class Tensor(object):
self
.
name
=
name
self
.
name
=
name
self
.
shape
=
shape
self
.
shape
=
shape
# ------------------------ Properies ------------------------
# ------------------------ Proper
t
ies ------------------------
@property
@property
def
expressions
(
self
):
def
expressions
(
self
):
...
...
Dragon/python/dragon/tools/board/app.py
View file @
d64a394
...
@@ -79,4 +79,4 @@ class DragonBoard(Process):
...
@@ -79,4 +79,4 @@ class DragonBoard(Process):
return
make_response
(
jsonify
(
sample_scalar
))
return
make_response
(
jsonify
(
sample_scalar
))
else
:
return
make_response
(
jsonify
(
sclar
))
else
:
return
make_response
(
jsonify
(
sclar
))
app
.
run
(
host
=
'0.0.0.0'
,
port
=
self
.
config
[
'port'
])
app
.
run
(
host
=
'0.0.0.0'
,
port
=
self
.
config
[
'port'
]
,
threaded
=
True
)
Dragon/python/requirements.txt
View file @
d64a394
numpy==1.12.1
numpy
six==1.10.0
six
protobuf==3.3.0
protobuf
lmdb==0.93
lmdb
opencv-python==3.1.0
opencv-python
Pillow==4.1.1
Pillow
\ No newline at end of file
\ No newline at end of file
README.md
View file @
d64a394
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
[*Win64-VS2015*](https://pan.baidu.com/s/1c2eX6lq) (OpenBLAS / Protobuf2.6 for VS2015 / CUDNN v7 / Microsoft MPI)
[*Win64-VS2015*](https://pan.baidu.com/s/1c2eX6lq) (OpenBLAS / Protobuf2.6 for VS2015 / CUDNN v7 / Microsoft MPI)
[*Linux64*](https://pan.baidu.com/s/1
qXPEOWG
) (OpenMPI)
[*Linux64*](https://pan.baidu.com/s/1
c2ChKHy
) (OpenMPI)
For Windows, ``python27/35/36.lib`` should be copied to ``Dragon/3rdparty/lib``, it depends on the version of Python.
For Windows, ``python27/35/36.lib`` should be copied to ``Dragon/3rdparty/lib``, it depends on the version of Python.
...
@@ -73,12 +73,12 @@
...
@@ -73,12 +73,12 @@
-
Run 3rdparty/setup_mpi.sh
-
Run 3rdparty/setup_mpi.sh
```Shell
```Shell
./setup_mpi.sh
bash
./setup_mpi.sh
```
```
- Install
- Install
```Shell
```Shell
sudo cp openmpi/install/bin/mpirun /usr/bin
sudo cp
3rdparty/
openmpi/install/bin/mpirun /usr/bin
```
```
#### Windows:
#### Windows:
- We use Microsoft MPI which can perfectly run at lastest Windows10
- We use Microsoft MPI which can perfectly run at lastest Windows10
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment