Repository navigation
fix test_var_base.py when FLAGS_enable_pir_api=True - #62686
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
| if not isinstance(dtype, paddle.dtype): | ||
| dtype = convert_np_dtype_to_dtype_(dtype) |
There was a problem hiding this comment.
对于 Variable 来说,应该只能是 VarType,但这里的 dtype 是不是可能是 DataType?
可以改成
if not isinstance(dtype, (DataType, VarType)):
dtype = convert_np_dtype_to_dtype_(dtype)
if isinstance(dtype, DataType):
dtype = paddle_type_to_proto_type[dtype]这样下面 1612 行看起来也不可能是 DataType 了
唔,不过我们已经有很多类似的代码了,是否可以抽成一个函数?
There was a problem hiding this comment.
根据后面的 comment,Variable 里是否不需要适配?
|
|
||
| attr_keys = ['block', 'dtype', 'type', 'name'] | ||
| attr_keys = ["block", "dtype", "type", "name"] | ||
| for attr in attr_keys: |
There was a problem hiding this comment.
原来 Variable 的 DataType 是从这里传进去的么?按理说 Variable 是不可能在 FLAGS_enable_pir_api 出现的
这里更合理的行为是使用 Value~可以看看好不好实现~
| a = paddle.rand([1]) | ||
| a_str = str(a.dtype) | ||
|
|
||
| expected = 'paddle.float32' |
There was a problem hiding this comment.
这里直接用 'paddle.float32' 是更合理的,虽然现在可能跑不通,但未来切换的时候肯定是要用 'paddle.float32' 的,所以这里先不改吧~
…hods.py, python/paddle/base/framework.py, and test/legacy_test/test_var_base.py
| dtype = convert_np_dtype_to_dtype_(dtype) | ||
| if isinstance(dtype, core.DataType): | ||
| dtype = paddle_type_to_proto_type[dtype] | ||
| dtype = convert_np_dtype_to_proto_type(dtype) |
There was a problem hiding this comment.
这是不是有点问题?如果 dtype 已经是 DataType 的话,这个 DataType 就会传到后面了
| if type(dtype) is str: | ||
| dtype = framework.convert_np_dtype_to_dtype_(dtype) | ||
|
|
||
| dtype = framework.convert_to_proto_type(dtype) |
There was a problem hiding this comment.
- 这里对于dtype的修改是不是应该放到
if t.place.is_gpu_place():内,然后应该改为proto_dtype = framework.convert_to_proto_type(dtype)吧,因为dtype变量后面还会用到dtype != t_used.dtype,如果都变成proto dtype的话应该会有问题吧 - 另外需要改动下test/ir/pir/cinn/symbolic/test_llama_unsqueeze_expand.py的40h,把bool改成string
|
下次不要在pr里大面积的把单引号改成双引号了,这样非常不好review :) |
好的 |
| s3 = paddle.shape(x)[1] | ||
|
|
||
| z = x.unsqueeze([1, 2]).cast(bool) | ||
| z = x.unsqueeze([1, 2]).cast(str) |

PR types
Others
PR changes
Others
Description
修复 FLAGS_enable_pir_api=True python3.11 test_var_base.py