提交 d9e6bf6e 编写于 作者: S Smit Hinsu 提交者: TensorFlower Gardener

Add auto-generated TensorFlow ShiftLeft and ShiftRight ops

PiperOrigin-RevId: 285832508
Change-Id: I35f79b5a6d8390bd62c4ae4e53fa5c5c4da30d2d
上级 caaefbc0
......@@ -2459,6 +2459,55 @@ def TF_LeakyReluOp : TF_Op<"LeakyRelu", [NoSideEffect, SameOperandsAndResultType
let hasFolder = 1;
}
def TF_LeftShiftOp : TF_Op<"LeftShift", [Broadcastable, NoSideEffect]>,
WithBroadcastableBinOpBuilder {
let summary = "Elementwise computes the bitwise left-shift of `x` and `y`.";
let description = [{
If `y` is negative, or greater than or equal to the width of `x` in bits the
result is implementation defined.
Example:
```python
import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
import numpy as np
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64]
for dtype in dtype_list:
lhs = tf.constant([-1, -5, -3, -14], dtype=dtype)
rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
left_shift_result = bitwise_ops.left_shift(lhs, rhs)
print(left_shift_result)
# This will print:
# tf.Tensor([ -32 -5 -128 0], shape=(4,), dtype=int8)
# tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int16)
# tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int32)
# tf.Tensor([ -32 -5 -384 -28672], shape=(4,), dtype=int64)
lhs = np.array([-2, 64, 101, 32], dtype=np.int8)
rhs = np.array([-1, -5, -3, -14], dtype=np.int8)
bitwise_ops.left_shift(lhs, rhs)
# <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2, 64, 101, 32], dtype=int8)>
```
}];
let arguments = (ins
TF_IntTensor:$x,
TF_IntTensor:$y
);
let results = (outs
TF_IntTensor:$z
);
TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>;
}
def TF_LessOp : TF_Op<"Less", [Broadcastable, NoSideEffect]>,
WithBroadcastableCmpOpBuilder {
let summary = "Returns the truth value of (x < y) element-wise.";
......@@ -4670,6 +4719,58 @@ reverse(t, dims) ==> [[[[8, 9, 10, 11],
TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<1>;
}
def TF_RightShiftOp : TF_Op<"RightShift", [Broadcastable, NoSideEffect]>,
WithBroadcastableBinOpBuilder {
let summary = "Elementwise computes the bitwise right-shift of `x` and `y`.";
let description = [{
Performs a logical shift for unsigned integer types, and an arithmetic shift
for signed integer types.
If `y` is negative, or greater than or equal to than the width of `x` in bits
the result is implementation defined.
Example:
```python
import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
import numpy as np
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64]
for dtype in dtype_list:
lhs = tf.constant([-1, -5, -3, -14], dtype=dtype)
rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
right_shift_result = bitwise_ops.right_shift(lhs, rhs)
print(right_shift_result)
# This will print:
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int8)
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int16)
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int32)
# tf.Tensor([-1 -5 -1 -1], shape=(4,), dtype=int64)
lhs = np.array([-2, 64, 101, 32], dtype=np.int8)
rhs = np.array([-1, -5, -3, -14], dtype=np.int8)
bitwise_ops.right_shift(lhs, rhs)
# <tf.Tensor: shape=(4,), dtype=int8, numpy=array([ -2, 64, 101, 32], dtype=int8)>
```
}];
let arguments = (ins
TF_IntTensor:$x,
TF_IntTensor:$y
);
let results = (outs
TF_IntTensor:$z
);
TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>;
}
def TF_RoundOp : TF_Op<"Round", [NoSideEffect, SameOperandsAndResultType]> {
let summary = [{
Rounds the values of a tensor to the nearest integer, element-wise.
......@@ -6151,7 +6252,7 @@ def TF_UniqueOp : TF_Op<"Unique", [NoSideEffect]> {
let description = [{
This operation returns a tensor `y` containing all of the unique elements of `x`
sorted in the same order that they occur in `x`; `x` does not need to be sorted.
This operation also returns a tensor `idx` the same size as `x` that contains
This operation also returns a tensor `idx` the same size as `x` that contains
the index of each value of `x` in the unique output `y`. In other words:
`y[idx[i]] = x[i] for i in [0, 1,...,rank(x) - 1]`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册