未验证 提交 c4b60efa 编写于 作者: A Aurelius84 提交者: GitHub

Fix segment Fault from set_value (#31891)

* Avoid raising warning while import paddle

* fix segment fault of set_value

* fix code style
上级 17030ff2
...@@ -2006,7 +2006,8 @@ class Variable(object): ...@@ -2006,7 +2006,8 @@ class Variable(object):
"paddle.Tensor to a paddle.Tensor, but received {}".format( "paddle.Tensor to a paddle.Tensor, but received {}".format(
type(value))) type(value)))
self.block.append_op( cur_block = default_main_program().current_block()
cur_block.append_op(
type="set_value", inputs=inputs, outputs={'Out': self}, attrs=attrs) type="set_value", inputs=inputs, outputs={'Out': self}, attrs=attrs)
return self return self
......
...@@ -106,6 +106,23 @@ class TestSetValueItemSlice4(TestSetValueApi): ...@@ -106,6 +106,23 @@ class TestSetValueItemSlice4(TestSetValueApi):
self.data[0:, 1:2, :] = self.value self.data[0:, 1:2, :] = self.value
class TestSetValueItemSliceInWhile(TestSetValueApi):
def _call_setitem(self, x):
def cond(i, x):
return i < 1
def body(i, x):
x[i] = self.value
i = i + 1
return i, x
i = paddle.zeros(shape=(1, ), dtype='int32')
i, x = paddle.fluid.layers.while_loop(cond, body, [i, x])
def _get_answer(self):
self.data[0] = self.value
# 1.2.2 step > 1 # 1.2.2 step > 1
class TestSetValueItemSliceStep(TestSetValueApi): class TestSetValueItemSliceStep(TestSetValueApi):
def set_shape(self): def set_shape(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册