Home | History | Annotate | Download | only in service
      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 #ifndef TENSORFLOW_COMPILER_XLA_SERVICE_VERSIONED_COMPUTATION_HANDLE_H_
     17 #define TENSORFLOW_COMPILER_XLA_SERVICE_VERSIONED_COMPUTATION_HANDLE_H_
     18 
     19 #include <ostream>
     20 
     21 #include "tensorflow/compiler/xla/types.h"
     22 #include "tensorflow/compiler/xla/xla_data.pb.h"
     23 
     24 namespace xla {
     25 
     26 // A data structure encapsulating a ComputationHandle and version value of that
     27 // computation. This object is used to unambiguously refer to a particular
     28 // computation in the service.
     29 struct VersionedComputationHandle {
     30   // A version value unambiguously specifying the state of the computation at a
     31   // particular point in time as it is being built. This value is the
     32   // ComputationDataHandle of the current root instruction.
     33   using Version = int64;
     34 
     35   ComputationHandle handle;
     36   Version version;
     37 
     38   string ToString() const;
     39   bool operator==(const VersionedComputationHandle& other) const {
     40     return (handle.handle() == other.handle.handle()) &&
     41            (version == other.version);
     42   }
     43   bool operator<(const VersionedComputationHandle& other) const {
     44     return ((handle.handle() < other.handle.handle()) ||
     45             ((handle.handle() == other.handle.handle()) &&
     46              (version < other.version)));
     47   }
     48 };
     49 
     50 std::ostream& operator<<(std::ostream& out,
     51                          const VersionedComputationHandle& versioned_handle);
     52 
     53 }  // namespace xla
     54 
     55 #endif  // TENSORFLOW_COMPILER_XLA_SERVICE_VERSIONED_COMPUTATION_HANDLE_H_
     56