T
- data type for z()
output@Operator(group="bitwise") public final class RightShift<T extends Number> extends PrimitiveOp implements Operand<T>
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:
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: id=151, shape=(4,), dtype=int8, numpy=array([ -2, 64, 101, 32], dtype=int8)>
operation
Modifier and Type | Method and Description |
---|---|
Output<T> |
asOutput()
Returns the symbolic handle of a tensor.
|
static <T extends Number> |
create(Scope scope,
Operand<T> x,
Operand<T> y)
Factory method to create a class wrapping a new RightShift operation.
|
Output<T> |
z() |
equals, hashCode, op, toString
public static <T extends Number> RightShift<T> create(Scope scope, Operand<T> x, Operand<T> y)
scope
- current scopex
- y
- public Output<T> asOutput()
Operand
Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.
asOutput
in interface Operand<T extends Number>
OperationBuilder.addInput(Output)
Copyright © 2022. All rights reserved.