1 | /* Copyright 2015 The TensorFlow Authors. All Rights Reserved. |
2 | |
3 | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | you may not use this file except in compliance with the License. |
5 | You may obtain a copy of the License at |
6 | |
7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | |
9 | Unless required by applicable law or agreed to in writing, software |
10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | See the License for the specific language governing permissions and |
13 | limitations under the License. |
14 | ==============================================================================*/ |
15 | |
16 | #include "tensorflow/core/framework/common_shape_fns.h" |
17 | #include "tensorflow/core/framework/numeric_op.h" |
18 | #include "tensorflow/core/framework/op.h" |
19 | #include "tensorflow/core/framework/shape_inference.h" |
20 | |
21 | namespace tensorflow { |
22 | |
23 | REGISTER_OP("Invert" ) |
24 | .Input("x: T" ) |
25 | .Output("y: T" ) |
26 | .Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}" ) |
27 | .SetShapeFn(shape_inference::UnchangedShape); |
28 | |
29 | #define BINARY_BITWISE() \ |
30 | Input("x: T") \ |
31 | .Input("y: T") \ |
32 | .Output("z: T") \ |
33 | .Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}") \ |
34 | .SetShapeFn(shape_inference::BroadcastBinaryOpShapeFn) |
35 | |
36 | #define BINARY_BITWISE_COMMUTATIVE() \ |
37 | Input("x: T") \ |
38 | .Input("y: T") \ |
39 | .Output("z: T") \ |
40 | .SetIsCommutative() \ |
41 | .Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}") \ |
42 | .SetShapeFn(shape_inference::BroadcastBinaryOpShapeFn) |
43 | |
44 | REGISTER_OP("PopulationCount" ) |
45 | .Input("x: T" ) |
46 | .Output("y: uint8" ) |
47 | .Attr("T: {int8, int16, int32, int64, uint8, uint16, uint32, uint64}" ) |
48 | .SetShapeFn(shape_inference::UnchangedShape); |
49 | |
50 | REGISTER_OP("BitwiseAnd" ).BINARY_BITWISE_COMMUTATIVE(); |
51 | |
52 | REGISTER_OP("BitwiseOr" ).BINARY_BITWISE_COMMUTATIVE(); |
53 | |
54 | REGISTER_OP("BitwiseXor" ).BINARY_BITWISE_COMMUTATIVE(); |
55 | |
56 | REGISTER_OP("LeftShift" ).BINARY_BITWISE(); |
57 | |
58 | REGISTER_OP("RightShift" ).BINARY_BITWISE(); |
59 | |
60 | } // namespace tensorflow |
61 | |