提交 308a9f1f authored 作者: notoraptor's avatar notoraptor

Try to fix segmentation fault related to last updates in cuDNN conv codes.

上级 b998dc61
...@@ -235,6 +235,7 @@ def struct_gen(args, struct_builders, blocks, sub): ...@@ -235,6 +235,7 @@ def struct_gen(args, struct_builders, blocks, sub):
# declares the storage # declares the storage
storage_decl = "\n".join(["PyObject* %s;" % arg for arg in args]) storage_decl = "\n".join(["PyObject* %s;" % arg for arg in args])
storage_init = "\n".join(["this->%s = NULL;" % arg for arg in args])
# in the constructor, sets the storage to the arguments # in the constructor, sets the storage to the arguments
storage_set = "\n".join(["this->%s = %s;" % (arg, arg) for arg in args]) storage_set = "\n".join(["this->%s = %s;" % (arg, arg) for arg in args])
# increments the storage's refcount in the constructor # increments the storage's refcount in the constructor
...@@ -290,6 +291,8 @@ def struct_gen(args, struct_builders, blocks, sub): ...@@ -290,6 +291,8 @@ def struct_gen(args, struct_builders, blocks, sub):
%(struct_decl)s %(struct_decl)s
%(name)s() { %(name)s() {
%(storage_init)s
// This is only somewhat safe because we: // This is only somewhat safe because we:
// 1) Are not a virtual class // 1) Are not a virtual class
// 2) Do not use any virtual classes in the members // 2) Do not use any virtual classes in the members
...@@ -299,7 +302,9 @@ def struct_gen(args, struct_builders, blocks, sub): ...@@ -299,7 +302,9 @@ def struct_gen(args, struct_builders, blocks, sub):
// now I am tired of chasing segfaults because // now I am tired of chasing segfaults because
// initialization code had an error and some pointer has // initialization code had an error and some pointer has
// a junk value. // a junk value.
#ifndef THEANO_DONT_MEMSET_STRUCT
memset(this, 0, sizeof(*this)); memset(this, 0, sizeof(*this));
#endif
} }
~%(name)s(void) { ~%(name)s(void) {
cleanup(); cleanup();
......
...@@ -9,6 +9,9 @@ hash_prefix = std::string("FWD|GPU#"); ...@@ -9,6 +9,9 @@ hash_prefix = std::string("FWD|GPU#");
int reuse_algo; int reuse_algo;
AlgoRec prev_algo; AlgoRec prev_algo;
std::string hash_prefix; std::string hash_prefix;
#define THEANO_DONT_MEMSET_STRUCT
#ifdef DEBUG #ifdef DEBUG
char algorithm_name[128]; char algorithm_name[128];
#endif #endif
......
...@@ -9,6 +9,9 @@ hash_prefix = std::string("GI|GPU#"); ...@@ -9,6 +9,9 @@ hash_prefix = std::string("GI|GPU#");
int reuse_algo; int reuse_algo;
AlgoRec prev_algo; AlgoRec prev_algo;
std::string hash_prefix; std::string hash_prefix;
#define THEANO_DONT_MEMSET_STRUCT
#ifdef DEBUG #ifdef DEBUG
char algorithm_name[128]; char algorithm_name[128];
#endif #endif
......
...@@ -9,6 +9,9 @@ hash_prefix = std::string("GW|GPU#"); ...@@ -9,6 +9,9 @@ hash_prefix = std::string("GW|GPU#");
int reuse_algo; int reuse_algo;
AlgoRec prev_algo; AlgoRec prev_algo;
std::string hash_prefix; std::string hash_prefix;
#define THEANO_DONT_MEMSET_STRUCT
#ifdef DEBUG #ifdef DEBUG
char algorithm_name[128]; char algorithm_name[128];
#endif #endif
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论