bug描述 Describe the Bug
paddle.isin works correctly with boolean input tensors in dynamic graph mode. However, when the same function is converted by paddle.jit.to_static(..., full_graph=True) with boolean InputSpec, static graph execution rejects the input and raises a dtype checker error.
This appears to be a dynamic/static inconsistency. Since the operator accepts bool tensors in eager mode, the static graph dtype checker should either also allow bool, or the dynamic mode should reject it consistently.
import traceback
import paddle
def target(x, y):
return paddle.isin(x, y)
x = paddle.to_tensor([[True, False], [False, True]], dtype="bool")
y = paddle.to_tensor([True], dtype="bool")
print("=== eager ===")
print(target(x, y))
print("\n=== static ===")
try:
static_target = paddle.jit.to_static(
target,
input_spec=[
paddle.static.InputSpec([2, 2], dtype="bool"),
paddle.static.InputSpec([1], dtype="bool"),
],
full_graph=True,
)
print(static_target(x, y))
print("not reproduced")
except Exception as exc:
print("BUG REPRODUCED: paddle.isin bool static dtype checker mismatch")
print(type(exc).__name__, str(exc).splitlines()[0])
traceback.print_exc(limit=5)
Output:
=== eager ===
Tensor(shape=[2, 2], dtype=bool, place=Place(cpu), stop_gradient=True,
[[True , False],
[False, True ]])
=== static ===
BUG REPRODUCED: paddle.isin bool static dtype checker mismatch
TypeError In transformed code:
Traceback (most recent call last):
File "/tmp/ipykernel_1242/2644694241.py", line 25, in <cell line: 0>
print(static_target(x, y))
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/paddle/jit/dy2static/program_translator.py", line 548, in __call__
return self._perform_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/dist-packages/paddle/jit/dy2static/program_translator.py", line 859, in _perform_call
error_data.raise_new_exception()
File "/usr/local/lib/python3.12/dist-packages/paddle/jit/dy2static/error.py", line 454, in raise_new_exception
raise new_exception from None
TypeError: In transformed code:
File "/tmp/ipykernel_1242/2644694241.py", line 6, in target
def target(x, y):
return paddle.isin(x, y)
~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
File "/usr/local/lib/python3.12/dist-packages/paddle/utils/decorator_utils.py", line 214, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.12/dist-packages/paddle/tensor/math.py", line 7884, in isin
check_variable_and_dtype(
File "/usr/local/lib/python3.12/dist-packages/paddle/base/data_feeder.py", line 170, in check_variable_and_dtype
check_dtype(input.dtype, input_name, expected_dtype, op_name, extra_message)
File "/usr/local/lib/python3.12/dist-packages/paddle/base/data_feeder.py", line 214, in check_dtype
raise TypeError(
TypeError: The data type of 'x' in isin must be ['uint16', 'float16', 'float32', 'float64', 'int32', 'int64'], but received bool.
其他补充信息 Additional Supplementary Information
Paddle Version: 3.3.0
bug描述 Describe the Bug
paddle.isin works correctly with boolean input tensors in dynamic graph mode. However, when the same function is converted by paddle.jit.to_static(..., full_graph=True) with boolean InputSpec, static graph execution rejects the input and raises a dtype checker error.
This appears to be a dynamic/static inconsistency. Since the operator accepts bool tensors in eager mode, the static graph dtype checker should either also allow bool, or the dynamic mode should reject it consistently.
Output:
其他补充信息 Additional Supplementary Information
Paddle Version: 3.3.0