提交 c3fdf3ae 编写于 作者: M minqiyang

Fix divide problem in CI

Fix pb_protobuf2 FromString problem
上级 db7d8136
......@@ -202,6 +202,7 @@ std::vector<std::string> OpDesc::AttrNames() const {
}
void OpDesc::SetAttr(const std::string &name, const Attribute &v) {
VLOG(11) << "SetAttr: " << Type() << ", " << name << ", " << v.which();
// NOTICE(minqiyang): pybind11 will take the empty list in python as
// the std::vector<int> type in C++; so we have to change the attr's type
// here if we meet this issue
......
......@@ -243,7 +243,7 @@ from .proto import framework_pb2
def serialize_op_decs(op_desc):
protostr = op_desc.serialize_to_string()
proto = framework_pb2.OpDesc.FromString(str(protostr))
proto = framework_pb2.OpDesc.FromString(six.binary_type(protostr))
return proto.__str__()
......
......@@ -225,7 +225,7 @@ def draw_block_graphviz(block, highlights=None, path="./temp.dot"):
graph = GraphPreviewGenerator("some graph")
# collect parameters and args
protostr = block.desc.serialize_to_string()
desc = framework_pb2.BlockDesc.FromString(str(protostr))
desc = framework_pb2.BlockDesc.FromString(six.binary_type(protostr))
def need_highlight(name):
if highlights is None: return False
......
......@@ -28,7 +28,7 @@ except ImportError as e:
"""NOTE: You may need to run \"export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH\"
if you encounters \"libmkldnn.so not found\" errors. If you have python
installed in other directory, replace \"/usr/local/lib\" with your own
directory. The original error is: \n""" + e.message)
directory. The original error is: \n""" + cpt.get_exception_message(e))
except Exception as e:
raise e
from . import unique_name
......@@ -574,6 +574,9 @@ class Operator(object):
attr_val = self.attrs[attr_name]
self._update_desc_attr(attr_name, attr_val)
import sys
print('self.attrs', self.attrs)
sys.stdout.flush()
self.desc.check_attrs()
if self.has_kernel(type):
self.desc.infer_var_type(self.block.desc)
......
......@@ -24,12 +24,12 @@ def conv2d_forward_naive(input, filter, group, conv_param):
out_c, f_c, f_h, f_w = filter.shape
assert f_c * group == in_c
assert np.mod(out_c, group) == 0
sub_out_c = out_c / group
sub_out_c = out_c // group
stride, pad, dilation = conv_param['stride'], conv_param['pad'], conv_param[
'dilation']
out_h = 1 + (in_h + 2 * pad[0] - (dilation[0] * (f_h - 1) + 1)) / stride[0]
out_w = 1 + (in_w + 2 * pad[1] - (dilation[1] * (f_w - 1) + 1)) / stride[1]
out_h = 1 + (in_h + 2 * pad[0] - (dilation[0] * (f_h - 1) + 1)) // stride[0]
out_w = 1 + (in_w + 2 * pad[1] - (dilation[1] * (f_w - 1) + 1)) // stride[1]
out = np.zeros((in_n, out_c, out_h, out_w))
d_bolck_h = (dilation[0] * (f_h - 1) + 1)
......@@ -160,7 +160,7 @@ class TestConv2dOp(OpTest):
self.stride = [1, 1]
self.input_size = [2, 3, 5, 5] # NCHW
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3]
def init_dilation(self):
......@@ -179,7 +179,7 @@ class TestWithPad(TestConv2dOp):
self.stride = [1, 1]
self.input_size = [2, 3, 5, 5] # NCHW
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3]
......@@ -189,7 +189,7 @@ class TestWithStride(TestConv2dOp):
self.stride = [2, 2]
self.input_size = [2, 3, 6, 6] # NCHW
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3]
......@@ -204,7 +204,7 @@ class TestWith1x1(TestConv2dOp):
self.stride = [1, 1]
self.input_size = [2, 3, 5, 5] # NCHW
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 1, 1]
def init_group(self):
......@@ -217,7 +217,7 @@ class TestWithDilation(TestConv2dOp):
self.stride = [1, 1]
self.input_size = [2, 3, 10, 10] # NCHW
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3]
def init_dilation(self):
......@@ -233,7 +233,7 @@ class TestWithInput1x1Filter1x1(TestConv2dOp):
self.stride = [1, 1]
self.input_size = [2, 3, 1, 1] # NCHW
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 1, 1]
def init_group(self):
......@@ -350,7 +350,7 @@ class TestDepthwiseConv(TestConv2dOp):
self.input_size = [2, 3, 5, 5] # NCHW
self.groups = 3
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3]
self.op_type = "depthwise_conv2d"
......@@ -362,7 +362,7 @@ class TestDepthwiseConv2(TestConv2dOp):
self.input_size = [2, 3, 5, 5] # NCHW
self.groups = 3
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [6, f_c, 3, 3]
self.op_type = "depthwise_conv2d"
......
......@@ -25,7 +25,7 @@ def conv2dtranspose_forward_naive(input_, filter_, attrs):
groups = attrs['groups']
assert in_c == f_c
out_c = f_out_c * groups
sub_in_c = in_c / groups
sub_in_c = in_c // groups
stride, pad, dilations = attrs['strides'], attrs['paddings'], attrs[
'dilations']
......@@ -258,7 +258,7 @@ class TestDepthwiseConvTranspose(TestConv2dTransposeOp):
self.input_size = [2, 8, 16, 16] # NCHW
self.groups = 8
assert np.mod(self.input_size[1], self.groups) == 0
f_c = self.input_size[1] / self.groups
f_c = self.input_size[1] // self.groups
self.filter_size = [self.input_size[1], f_c, 4, 4]
self.op_type = "depthwise_conv2d_transpose"
......
......@@ -34,7 +34,7 @@ class TestLRNOp(OpTest):
return x + 1
def get_out(self):
start = -(self.n - 1) / 2
start = -(self.n - 1) // 2
end = start + self.n
mid = np.empty((self.N, self.C, self.H, self.W)).astype("float32")
......
......@@ -15,6 +15,7 @@
import unittest
import paddle.fluid.core as core
import paddle.fluid.compat as cpt
from paddle.fluid.framework import Program, default_startup_program
......@@ -29,13 +30,13 @@ class TestOperator(unittest.TestCase):
self.assertFail()
except ValueError as v_err:
self.assertEqual(
v_err.message,
cpt.get_exception_message(v_err),
"`type` to initilized an Operator can not be None.")
try:
block.append_op(type="no_such_op")
self.assertFail()
except ValueError as a_err:
self.assertEqual(a_err.message,
self.assertEqual(cpt.get_exception_message(a_err),
"Operator \"no_such_op\" has not been registered.")
def test_op_desc_creation(self):
......
......@@ -33,7 +33,7 @@ def squeeze_excitation(input, num_channels, reduction_ratio):
pool = fluid.layers.reduce_mean(input=reshape, dim=2)
squeeze = fluid.layers.fc(input=pool,
size=num_channels / reduction_ratio,
size=num_channels // reduction_ratio,
act='relu')
excitation = fluid.layers.fc(input=squeeze,
size=num_channels,
......@@ -49,7 +49,7 @@ def conv_bn_layer(input, num_filters, filter_size, stride=1, groups=1,
num_filters=num_filters,
filter_size=filter_size,
stride=stride,
padding=(filter_size - 1) / 2,
padding=(filter_size - 1) // 2,
groups=groups,
act=None,
bias_attr=False)
......
......@@ -14,7 +14,7 @@
from collections import defaultdict
from .. import core
from .. import compat
from .. import compat as cpt
from ..framework import Program, default_main_program, Parameter
from ..backward import _rename_arg_
from functools import reduce
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册