|
|
|
@ -133,6 +133,10 @@ __all__ = [
|
|
|
|
|
'elementwise_max',
|
|
|
|
|
'elementwise_min',
|
|
|
|
|
'elementwise_pow',
|
|
|
|
|
'logical_and',
|
|
|
|
|
'logical_or',
|
|
|
|
|
'logical_xor',
|
|
|
|
|
'logical_not',
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -6616,3 +6620,100 @@ for func in [
|
|
|
|
|
"act (basestring|None): Activation applied to the output.",
|
|
|
|
|
"name (basestring|None): Name of the output."
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _logical_op(op_name, x, y, name=None, out=None, binary_op=True):
|
|
|
|
|
helper = LayerHelper(op_name, **locals())
|
|
|
|
|
|
|
|
|
|
assert x.dtype == y.dtype
|
|
|
|
|
|
|
|
|
|
if out is None:
|
|
|
|
|
if name is None:
|
|
|
|
|
out = helper.create_tmp_variable(dtype=x.dtype)
|
|
|
|
|
else:
|
|
|
|
|
out = helper.create_variable(
|
|
|
|
|
name=name, dtype=x.dtype, persistable=False)
|
|
|
|
|
|
|
|
|
|
if binary_op:
|
|
|
|
|
helper.append_op(
|
|
|
|
|
type=op_name, inputs={"X": x,
|
|
|
|
|
"Y": y}, outputs={"Out": out})
|
|
|
|
|
else:
|
|
|
|
|
helper.append_op(type=op_name, inputs={"X": x}, outputs={"Out": out})
|
|
|
|
|
|
|
|
|
|
return out
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@templatedoc()
|
|
|
|
|
def logical_and(x, y, name=None, out=None):
|
|
|
|
|
"""
|
|
|
|
|
${comment}
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x(${x_type}): ${x_comment}
|
|
|
|
|
y(${y_type}): ${y_comment}
|
|
|
|
|
out(Tensor): Output tensor of logical operation.
|
|
|
|
|
name(basestring|None): Name of the output.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
out(${out_type}): ${out_comment}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
return _logical_op(
|
|
|
|
|
op_name="logical_and", x=x, y=y, name=name, out=out, binary_op=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@templatedoc()
|
|
|
|
|
def logical_or(x, y, name=None, out=None):
|
|
|
|
|
"""
|
|
|
|
|
${comment}
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x(${x_type}): ${x_comment}
|
|
|
|
|
y(${y_type}): ${y_comment}
|
|
|
|
|
out(Tensor): Output tensor of logical operation.
|
|
|
|
|
name(basestring|None): Name of the output.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
out(${out_type}): ${out_comment}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
return _logical_op(
|
|
|
|
|
op_name="logical_or", x=x, y=y, name=name, out=out, binary_op=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@templatedoc()
|
|
|
|
|
def logical_xor(x, y, name=None, out=None):
|
|
|
|
|
"""
|
|
|
|
|
${comment}
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x(${x_type}): ${x_comment}
|
|
|
|
|
y(${y_type}): ${y_comment}
|
|
|
|
|
out(Tensor): Output tensor of logical operation.
|
|
|
|
|
name(basestring|None): Name of the output.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
out(${out_type}): ${out_comment}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
return _logical_op(
|
|
|
|
|
op_name="logical_xor", x=x, y=y, name=name, out=out, binary_op=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@templatedoc()
|
|
|
|
|
def logical_not(x, name=None, out=None):
|
|
|
|
|
"""
|
|
|
|
|
${comment}
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
x(${x_type}): ${x_comment}
|
|
|
|
|
out(Tensor): Output tensor of logical operation.
|
|
|
|
|
name(basestring|None): Name of the output.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
out(${out_type}): ${out_comment}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
return _logical_op(
|
|
|
|
|
op_name="logical_not", x=x, y=None, name=name, out=out, binary_op=False)
|
|
|
|
|