File tree Expand file tree Collapse file tree 4 files changed +10
-8
lines changed
python/paddle/v2/framework Expand file tree Collapse file tree 4 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ limitations under the License. */
15
15
#include " paddle/pybind/protobuf.h"
16
16
17
17
#include < mutex> // for call_once
18
+ #include < unordered_map>
18
19
#include " gflags/gflags.h"
19
20
#include " paddle/framework/backward.h"
20
21
#include " paddle/framework/executor.h"
@@ -42,9 +43,9 @@ limitations under the License. */
42
43
43
44
namespace paddle {
44
45
namespace pybind {
45
- static size_t UniqueIntegerGenerator () {
46
- static std::atomic<size_t > generator ;
47
- return generator .fetch_add (1 );
46
+ static size_t UniqueIntegerGenerator (const std::string &prefix ) {
47
+ static std::unordered_map<std::string, std:: atomic<size_t >> generators ;
48
+ return generators[prefix] .fetch_add (1 );
48
49
}
49
50
50
51
std::once_flag gflags_init_flag;
Original file line number Diff line number Diff line change @@ -119,8 +119,9 @@ def type(self):
119
119
120
120
@staticmethod
121
121
def _unique_var_name_ ():
122
- uid = core .unique_integer () # unique during whole process.
123
- return "_generated_var_%d" % uid
122
+ prefix = "_generated_var"
123
+ uid = core .unique_integer (prefix ) # unique during whole process.
124
+ return "_" .join ([prefix , str (uid )])
124
125
125
126
@staticmethod
126
127
def _convert_np_dtype_to_dtype_ (np_dtype ):
Original file line number Diff line number Diff line change 8
8
9
9
10
10
def unique_name (prefix ):
11
- uid = core .unique_integer () # unique during whole process.
11
+ uid = core .unique_integer (prefix ) # unique during whole process.
12
12
return "_" .join ([prefix , str (uid )])
13
13
14
14
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ def test_batch_norm_layer(self):
37
37
layers .batch_norm (
38
38
input = images , program = program , init_program = init_program )
39
39
40
- #print str(program)
40
+ # print str(program)
41
41
42
42
def test_dropout_layer (self ):
43
43
program = Program ()
@@ -53,7 +53,7 @@ def test_dropout_layer(self):
53
53
program = program ,
54
54
init_program = init_program )
55
55
56
- #print str(program)
56
+ # print str(program)
57
57
58
58
def test_img_conv_group (self ):
59
59
program = Program ()
You can’t perform that action at this time.
0 commit comments