提交 ff07dc31 编写于 作者: J JiabinYang

test=develop

上级 39d39775
...@@ -91,8 +91,8 @@ class ReorgOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -91,8 +91,8 @@ class ReorgOpMaker : public framework::OpProtoAndCheckerMaker {
Examples: Examples:
1. Given a 3-D tensor Input(X) with a shape [2048, 26, 26], and the stride is 2, the reorg operator will transform Input(X) 1. Given a 4-D tensor Input(X) with a shape [128, 2048, 26, 26], and the stride is 2, the reorg operator will transform Input(X)
into a 3-D tensor with shape [2048, 13, 13] and leaving Input(X)'s data unchanged. into a 4-D tensor with shape [128, 2048, 13, 13] and leaving Input(X)'s data unchanged.
)DOC"); )DOC");
} }
......
...@@ -7470,8 +7470,8 @@ def reorg(x, stride, name=None): ...@@ -7470,8 +7470,8 @@ def reorg(x, stride, name=None):
x=data, stride=2) x=data, stride=2)
""" """
if not (isinstance(stride, long)): if not (isinstance(stride, int)):
raise ValueError("stride must be a python long") raise ValueError("stride must be a python Int")
helper = LayerHelper("reorg", **locals()) helper = LayerHelper("reorg", **locals())
if name is None: if name is None:
......
...@@ -256,7 +256,7 @@ class TestBook(unittest.TestCase): ...@@ -256,7 +256,7 @@ class TestBook(unittest.TestCase):
shape=[32, 9, 6, 6], shape=[32, 9, 6, 6],
append_batch_size=False, append_batch_size=False,
dtype='float32') dtype='float32')
self.assertIsNotNone(layers.reorg(data, long(3))) self.assertIsNotNone(layers.reorg(data, 3))
print(str(program)) print(str(program))
def test_sequence_unsqueeze(self): def test_sequence_unsqueeze(self):
......
...@@ -22,16 +22,16 @@ from op_test import OpTest ...@@ -22,16 +22,16 @@ from op_test import OpTest
class TestReorgOp(OpTest): class TestReorgOp(OpTest):
@staticmethod @staticmethod
def helper(in_, width, height, channel, batch, stride, forward, out_): def helper(in_, width, height, channel, batch, stride, forward, out_):
channel_out = channel / (stride * stride) channel_out = channel // (stride * stride)
for b in range(batch): for b in range(batch):
for k in range(channel): for k in range(channel):
for j in range(height): for j in range(height):
for i in range(width): for i in range(width):
in_index = i + width * (j + height * (k + channel * b)) in_index = i + width * (j + height * (k + channel * b))
channel2 = k % channel_out channel2 = k % channel_out
offset = k / channel_out offset = k // channel_out
width2 = i * stride + offset % stride width2 = i * stride + offset % stride
height2 = j * stride + offset / stride height2 = j * stride + offset // stride
out_index = width2 + width * stride * ( out_index = width2 + width * stride * (
height2 + height * stride * height2 + height * stride *
(channel2 + channel_out * b)) (channel2 + channel_out * b))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册