1 | /* Copyright 2017 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/op.h" |
18 | #include "tensorflow/core/framework/shape_inference.h" |
19 | |
20 | namespace tensorflow { |
21 | |
22 | using shape_inference::InferenceContext; |
23 | using shape_inference::ShapeHandle; |
24 | |
25 | REGISTER_OP("InfeedDequeue") |
26 | .Output("output: dtype") |
27 | .Attr("dtype: type") |
28 | .Attr("shape: shape") |
29 | .SetIsStateful() |
30 | .SetShapeFn(shape_inference::ExplicitShape); |
31 | |
32 | REGISTER_OP("InfeedEnqueue") |
33 | .Input("input: dtype") |
34 | .Attr("dtype: type") |
35 | .Attr("shape: shape = {}") |
36 | .Attr("layout: list(int) = []") |
37 | .Attr("device_ordinal: int = -1") |
38 | .SetShapeFn(shape_inference::NoOutputs) |
39 | .SetIsStateful(); |
40 | |
41 | REGISTER_OP("InfeedEnqueueTuple") |
42 | .Input("inputs: dtypes") |
43 | .Attr("dtypes: list(type)") |
44 | .Attr("shapes: list(shape)") |
45 | .Attr("layouts: list(int) = []") |
46 | .Attr("device_ordinal: int = -1") |
47 | .SetShapeFn(shape_inference::NoOutputs) |
48 | .SetIsStateful(); |
49 | |
50 | REGISTER_OP("InfeedDequeueTuple") |
51 | .Output("outputs: dtypes") |
52 | .Attr("dtypes: list(type)") |
53 | .Attr("shapes: list(shape)") |
54 | .SetIsStateful() |
55 | .SetShapeFn([](InferenceContext* c) { |
56 | std::vector<PartialTensorShape> shapes; |
57 | TF_RETURN_IF_ERROR(c->GetAttr("shapes", &shapes)); |
58 | for (int i = 0; i < shapes.size(); ++i) { |
59 | ShapeHandle out; |
60 | TF_RETURN_IF_ERROR(c->MakeShapeFromPartialTensorShape(shapes[i], &out)); |
61 | c->set_output(i, out); |
62 | } |
63 | return OkStatus(); |
64 | }); |
65 | |
66 | REGISTER_OP("Prelinearize") |
67 | .Input("input: dtype") |
68 | .Attr("dtype: type") |
69 | .Attr("shape: shape = {}") |
70 | .Attr("layout: list(int) = []") |
71 | .Output("output: variant") |
72 | .SetShapeFn(shape_inference::ScalarShape); |
73 | |
74 | REGISTER_OP("PrelinearizeTuple") |
75 | .Input("inputs: dtypes") |
76 | .Attr("dtypes: list(type)") |
77 | .Attr("shapes: list(shape)") |
78 | .Attr("layouts: list(int) = []") |
79 | .Output("output: variant") |
80 | .SetShapeFn(shape_inference::ScalarShape); |
81 | |
82 | REGISTER_OP("InfeedEnqueuePrelinearizedBuffer") |
83 | .Input("input: variant") |
84 | .Attr("device_ordinal: int = -1") |
85 | .SetShapeFn(shape_inference::NoOutputs); |
86 | |
87 | } // namespace tensorflow |
88 |