-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeStyle][Ruff][BUAA][G-[161-170]] Fix ruff RUF005 diagnostic for 9 files #67344
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -147,13 +147,11 @@ def test_sample_shape(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () | |||
+ tuple(paddle.squeeze(self._paddle_chi2.df).shape), | |||
'expect': (*paddle.squeeze(self._paddle_chi2.df).shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'expect': (*paddle.squeeze(self._paddle_chi2.df).shape,), | |
'expect': tuple(paddle.squeeze(self._paddle_chi2.df).shape), |
这样就好了吧
@@ -179,13 +179,15 @@ def test_sample_shape(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () | |||
+ tuple(paddle.squeeze(self._paddle_expon.rate).shape), | |||
'expect': (*paddle.squeeze(self._paddle_expon.rate).shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这没改啊
@@ -217,13 +219,15 @@ def test_rsample_shape(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () | |||
+ tuple(paddle.squeeze(self._paddle_expon.rate).shape), | |||
'expect': (*paddle.squeeze(self._paddle_expon.rate).shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -230,11 +230,11 @@ def test_sample_shape(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () + np.squeeze(self.rate).shape, | |||
'expect': (*np.squeeze(self.rate).shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -251,11 +251,11 @@ def test_rsample_shape(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () + np.squeeze(self.rate).shape, | |||
'expect': (*np.squeeze(self.rate).shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -102,13 +102,15 @@ def test_sample_shape(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () | |||
+ tuple(paddle.squeeze(self._paddle_geom.probs).shape), | |||
'expect': (*paddle.squeeze(self._paddle_geom.probs).shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -140,13 +142,15 @@ def test_rsample_shape(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () | |||
+ tuple(paddle.squeeze(self._paddle_geom.probs).shape), | |||
'expect': (*paddle.squeeze(self._paddle_geom.probs).shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -54,7 +54,7 @@ def gen_cases(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () + extra_shape, | |||
'expect': (*extra_shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
@@ -78,11 +78,11 @@ def gen_cases(self): | |||
cases = [ | |||
{ | |||
'input': (), | |||
'expect': () + extra_shape, | |||
'expect': (*extra_shape,), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wizard-ZP 麻烦这整个文件都恢复下
2024-08-12 21:44:00 ======================================================================
2024-08-12 21:44:00 ERROR: test_base_model__sot_pt (test_seq2seq.TestSeq2seq)
2024-08-12 21:44:00 ----------------------------------------------------------------------
2024-08-12 21:44:00 Traceback (most recent call last):
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\executor_cache.py", line 211, in start_translate
2024-08-12 21:44:00 new_custom_code, guard_fn = simulator.transform()
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\opcode_executor.py", line 1628, in transform
2024-08-12 21:44:00 self.run()
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\opcode_executor.py", line 555, in run
2024-08-12 21:44:00 is_stop = self.step(cur_instr)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\opcode_executor.py", line 600, in step
2024-08-12 21:44:00 return getattr(self, opname)(instr) # run single step.
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\opcode_executor.py", line 1566, in LIST_EXTEND
2024-08-12 21:44:00 BuiltinVariable(list.extend, self._graph, tracker=DanglingTracker())(
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\variables\callable.py", line 85, in __call__
2024-08-12 21:44:00 return self.call_function(*args, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\variables\callable.py", line 674, in call_function
2024-08-12 21:44:00 raise BreakGraphError(
2024-08-12 21:44:00 paddle.jit.sot.utils.exceptions.BreakGraphError: Not support builtin function: extend with args: Args(ListVariable, RangeVariable)
2024-08-12 21:44:00 During handling of the above exception, another exception occurred:
2024-08-12 21:44:00 Traceback (most recent call last):
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\test\dygraph_to_static\dygraph_to_static_utils.py", line 153, in impl
2024-08-12 21:44:00 fn(*args, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\test\dygraph_to_static\dygraph_to_static_utils.py", line 211, in impl
2024-08-12 21:44:00 ir_outs = fn(*args, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\test\dygraph_to_static\test_seq2seq.py", line 235, in test_base_model
2024-08-12 21:44:00 self._test_train(attn_model=False)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\test\dygraph_to_static\test_seq2seq.py", line 217, in _test_train
2024-08-12 21:44:00 static_loss = self.run_static(mode="train", attn_model=attn_model)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\test\dygraph_to_static\test_seq2seq.py", line 211, in run_static
2024-08-12 21:44:00 return train(self.args, attn_model)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\test\dygraph_to_static\test_seq2seq.py", line 98, in train
2024-08-12 21:44:00 loss = model(input_data_feed)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\nn\layer\layers.py", line 1531, in __call__
2024-08-12 21:44:00 return self.forward(*inputs, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\dy2static\program_translator.py", line 502, in __call__
2024-08-12 21:44:00 return self._perform_call(*args, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\dy2static\program_translator.py", line 743, in _perform_call
2024-08-12 21:44:00 return traced_fun(*args, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\translate.py", line 118, in impl
2024-08-12 21:44:00 return impl_sot(*args, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\translate.py", line 102, in impl_sot
2024-08-12 21:44:00 raise e
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\translate.py", line 100, in impl_sot
2024-08-12 21:44:00 outs = fn(*args, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\test\dygraph_to_static\seq2seq_dygraph_model.py", line 203, in #forward_7374b
2024-08-12 21:44:00 def forward(self, inputs):
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\variables\basic.py", line 1083, in __call__
2024-08-12 21:44:00 return func(*args[1:], **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\translate.py", line 90, in callback
2024-08-12 21:44:00 return eval_frame_callback(frame, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\eval_frame_callback.py", line 69, in eval_frame_callback
2024-08-12 21:44:00 custom_code = OpcodeExecutorCache()(frame, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\executor_cache.py", line 84, in __call__
2024-08-12 21:44:00 new_custom_code, guard_fn = self.translate(frame, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\executor_cache.py", line 159, in translate
2024-08-12 21:44:00 custom_new_code, guard_fn = start_translate(frame, **kwargs)
2024-08-12 21:44:00 File "C:\home\workspace\Paddle\build\python\paddle\jit\sot\opcode_translator\executor\executor_cache.py", line 216, in start_translate
2024-08-12 21:44:00 raise RuntimeError(
2024-08-12 21:44:00 RuntimeError: Found BreakGraphError raised, it should not be catch at start_translate!
2024-08-12 21:44:00 Not support builtin function: extend with args: Args(ListVariable, RangeVariable)
这里记个 TODO @gouzil:
看样子是 SOT 的问题,目测是 UNPACK
没装捕获 breakgraph 的装饰器导致直接 raise 到最外层了,挂掉是不符合预期的,可以先确认下问题,修复这个没有触发打断而直接 raise 的问题,收紧正确性
然后灵活看下打断是否方便支持,相关代码在原语法情况下是否支持,是如何支持的,修改后的与原来有什么不同,为什么不支持
只是 TODO,灵活看下就好
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Category
User Experience
PR Types
Devs
Description
修复G161-169 RUF005 的
Ruff
规则test/distribution/test_distribution_chi2_static.py
test/distribution/test_distribution_exponential.py
test/distribution/test_distribution_exponential_static.py
test/distribution/test_distribution_gamma.py
test/distribution/test_distribution_gamma_static.py
test/distribution/test_distribution_geometric.py
test/distribution/test_distribution_lkj_cholesky.py
test/distribution/test_distribution_lkj_cholesky_static.py
test/dygraph_to_static/bert_utils.py
Related Links