Home | History | Annotate | Download | only in ops
      1 /* Copyright 2016 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 
     19 namespace tensorflow {
     20 
     21 using shape_inference::InferenceContext;
     22 using shape_inference::ShapeHandle;
     23 
     24 REGISTER_OP("ObtainNext")
     25     .Input("list: string")
     26     .Input("counter: Ref(int64)")
     27     .Output("out_element: string")
     28     .SetShapeFn([](InferenceContext* c) {
     29       ShapeHandle unused_input, input1;
     30       TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 1, &unused_input));
     31       TF_RETURN_IF_ERROR(c->WithRank(c->input(1), 0, &input1));
     32       c->set_output(0, c->Scalar());
     33       return Status::OK();
     34     })
     35     .Doc(R"doc(
     36 Takes a list and returns the next based on a counter in a round-robin fashion.
     37 
     38 Returns the element in the list at the new position of the counter, so if you
     39 want to circle the list around start by setting the counter value = -1.
     40 
     41 list: A list of strings
     42 counter: A reference to an int64 variable
     43 )doc");
     44 
     45 }  // namespace tensorflow
     46