// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: second/protos/similarity.proto

#include "second/protos/similarity.pb.h"

#include <algorithm>

#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>

PROTOBUF_PRAGMA_INIT_SEG

namespace _pb = ::PROTOBUF_NAMESPACE_ID;
namespace _pbi = _pb::internal;

namespace second {
namespace protos {
PROTOBUF_CONSTEXPR RegionSimilarityCalculator::RegionSimilarityCalculator(
    ::_pbi::ConstantInitialized): _impl_{
    /*decltype(_impl_.region_similarity_)*/{}
  , /*decltype(_impl_._cached_size_)*/{}
  , /*decltype(_impl_._oneof_case_)*/{}} {}
struct RegionSimilarityCalculatorDefaultTypeInternal {
  PROTOBUF_CONSTEXPR RegionSimilarityCalculatorDefaultTypeInternal()
      : _instance(::_pbi::ConstantInitialized{}) {}
  ~RegionSimilarityCalculatorDefaultTypeInternal() {}
  union {
    RegionSimilarityCalculator _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RegionSimilarityCalculatorDefaultTypeInternal _RegionSimilarityCalculator_default_instance_;
PROTOBUF_CONSTEXPR RotateIouSimilarity::RotateIouSimilarity(
    ::_pbi::ConstantInitialized) {}
struct RotateIouSimilarityDefaultTypeInternal {
  PROTOBUF_CONSTEXPR RotateIouSimilarityDefaultTypeInternal()
      : _instance(::_pbi::ConstantInitialized{}) {}
  ~RotateIouSimilarityDefaultTypeInternal() {}
  union {
    RotateIouSimilarity _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 RotateIouSimilarityDefaultTypeInternal _RotateIouSimilarity_default_instance_;
PROTOBUF_CONSTEXPR NearestIouSimilarity::NearestIouSimilarity(
    ::_pbi::ConstantInitialized) {}
struct NearestIouSimilarityDefaultTypeInternal {
  PROTOBUF_CONSTEXPR NearestIouSimilarityDefaultTypeInternal()
      : _instance(::_pbi::ConstantInitialized{}) {}
  ~NearestIouSimilarityDefaultTypeInternal() {}
  union {
    NearestIouSimilarity _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 NearestIouSimilarityDefaultTypeInternal _NearestIouSimilarity_default_instance_;
PROTOBUF_CONSTEXPR DistanceSimilarity::DistanceSimilarity(
    ::_pbi::ConstantInitialized): _impl_{
    /*decltype(_impl_.distance_norm_)*/0
  , /*decltype(_impl_.with_rotation_)*/false
  , /*decltype(_impl_.rotation_alpha_)*/0
  , /*decltype(_impl_._cached_size_)*/{}} {}
struct DistanceSimilarityDefaultTypeInternal {
  PROTOBUF_CONSTEXPR DistanceSimilarityDefaultTypeInternal()
      : _instance(::_pbi::ConstantInitialized{}) {}
  ~DistanceSimilarityDefaultTypeInternal() {}
  union {
    DistanceSimilarity _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 DistanceSimilarityDefaultTypeInternal _DistanceSimilarity_default_instance_;
}  // namespace protos
}  // namespace second
static ::_pb::Metadata file_level_metadata_second_2fprotos_2fsimilarity_2eproto[4];
static constexpr ::_pb::EnumDescriptor const** file_level_enum_descriptors_second_2fprotos_2fsimilarity_2eproto = nullptr;
static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_second_2fprotos_2fsimilarity_2eproto = nullptr;

const uint32_t TableStruct_second_2fprotos_2fsimilarity_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::second::protos::RegionSimilarityCalculator, _internal_metadata_),
  ~0u,  // no _extensions_
  PROTOBUF_FIELD_OFFSET(::second::protos::RegionSimilarityCalculator, _impl_._oneof_case_[0]),
  ~0u,  // no _weak_field_map_
  ~0u,  // no _inlined_string_donated_
  ::_pbi::kInvalidFieldOffsetTag,
  ::_pbi::kInvalidFieldOffsetTag,
  ::_pbi::kInvalidFieldOffsetTag,
  PROTOBUF_FIELD_OFFSET(::second::protos::RegionSimilarityCalculator, _impl_.region_similarity_),
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::second::protos::RotateIouSimilarity, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  ~0u,  // no _inlined_string_donated_
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::second::protos::NearestIouSimilarity, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  ~0u,  // no _inlined_string_donated_
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::second::protos::DistanceSimilarity, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  ~0u,  // no _inlined_string_donated_
  PROTOBUF_FIELD_OFFSET(::second::protos::DistanceSimilarity, _impl_.distance_norm_),
  PROTOBUF_FIELD_OFFSET(::second::protos::DistanceSimilarity, _impl_.with_rotation_),
  PROTOBUF_FIELD_OFFSET(::second::protos::DistanceSimilarity, _impl_.rotation_alpha_),
};
static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
  { 0, -1, -1, sizeof(::second::protos::RegionSimilarityCalculator)},
  { 10, -1, -1, sizeof(::second::protos::RotateIouSimilarity)},
  { 16, -1, -1, sizeof(::second::protos::NearestIouSimilarity)},
  { 22, -1, -1, sizeof(::second::protos::DistanceSimilarity)},
};

static const ::_pb::Message* const file_default_instances[] = {
  &::second::protos::_RegionSimilarityCalculator_default_instance_._instance,
  &::second::protos::_RotateIouSimilarity_default_instance_._instance,
  &::second::protos::_NearestIouSimilarity_default_instance_._instance,
  &::second::protos::_DistanceSimilarity_default_instance_._instance,
};

const char descriptor_table_protodef_second_2fprotos_2fsimilarity_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
  "\n\036second/protos/similarity.proto\022\rsecond"
  ".protos\"\377\001\n\032RegionSimilarityCalculator\022C"
  "\n\025rotate_iou_similarity\030\001 \001(\0132\".second.p"
  "rotos.RotateIouSimilarityH\000\022E\n\026nearest_i"
  "ou_similarity\030\002 \001(\0132#.second.protos.Near"
  "estIouSimilarityH\000\022@\n\023distance_similarit"
  "y\030\003 \001(\0132!.second.protos.DistanceSimilari"
  "tyH\000B\023\n\021region_similarity\"\025\n\023RotateIouSi"
  "milarity\"\026\n\024NearestIouSimilarity\"Z\n\022Dist"
  "anceSimilarity\022\025\n\rdistance_norm\030\001 \001(\002\022\025\n"
  "\rwith_rotation\030\002 \001(\010\022\026\n\016rotation_alpha\030\003"
  " \001(\002b\006proto3"
  ;
static ::_pbi::once_flag descriptor_table_second_2fprotos_2fsimilarity_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_second_2fprotos_2fsimilarity_2eproto = {
    false, false, 452, descriptor_table_protodef_second_2fprotos_2fsimilarity_2eproto,
    "second/protos/similarity.proto",
    &descriptor_table_second_2fprotos_2fsimilarity_2eproto_once, nullptr, 0, 4,
    schemas, file_default_instances, TableStruct_second_2fprotos_2fsimilarity_2eproto::offsets,
    file_level_metadata_second_2fprotos_2fsimilarity_2eproto, file_level_enum_descriptors_second_2fprotos_2fsimilarity_2eproto,
    file_level_service_descriptors_second_2fprotos_2fsimilarity_2eproto,
};
PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_second_2fprotos_2fsimilarity_2eproto_getter() {
  return &descriptor_table_second_2fprotos_2fsimilarity_2eproto;
}

// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_second_2fprotos_2fsimilarity_2eproto(&descriptor_table_second_2fprotos_2fsimilarity_2eproto);
namespace second {
namespace protos {

// ===================================================================

class RegionSimilarityCalculator::_Internal {
 public:
  static const ::second::protos::RotateIouSimilarity& rotate_iou_similarity(const RegionSimilarityCalculator* msg);
  static const ::second::protos::NearestIouSimilarity& nearest_iou_similarity(const RegionSimilarityCalculator* msg);
  static const ::second::protos::DistanceSimilarity& distance_similarity(const RegionSimilarityCalculator* msg);
};

const ::second::protos::RotateIouSimilarity&
RegionSimilarityCalculator::_Internal::rotate_iou_similarity(const RegionSimilarityCalculator* msg) {
  return *msg->_impl_.region_similarity_.rotate_iou_similarity_;
}
const ::second::protos::NearestIouSimilarity&
RegionSimilarityCalculator::_Internal::nearest_iou_similarity(const RegionSimilarityCalculator* msg) {
  return *msg->_impl_.region_similarity_.nearest_iou_similarity_;
}
const ::second::protos::DistanceSimilarity&
RegionSimilarityCalculator::_Internal::distance_similarity(const RegionSimilarityCalculator* msg) {
  return *msg->_impl_.region_similarity_.distance_similarity_;
}
void RegionSimilarityCalculator::set_allocated_rotate_iou_similarity(::second::protos::RotateIouSimilarity* rotate_iou_similarity) {
  ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
  clear_region_similarity();
  if (rotate_iou_similarity) {
    ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
      ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(rotate_iou_similarity);
    if (message_arena != submessage_arena) {
      rotate_iou_similarity = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
          message_arena, rotate_iou_similarity, submessage_arena);
    }
    set_has_rotate_iou_similarity();
    _impl_.region_similarity_.rotate_iou_similarity_ = rotate_iou_similarity;
  }
  // @@protoc_insertion_point(field_set_allocated:second.protos.RegionSimilarityCalculator.rotate_iou_similarity)
}
void RegionSimilarityCalculator::set_allocated_nearest_iou_similarity(::second::protos::NearestIouSimilarity* nearest_iou_similarity) {
  ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
  clear_region_similarity();
  if (nearest_iou_similarity) {
    ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
      ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(nearest_iou_similarity);
    if (message_arena != submessage_arena) {
      nearest_iou_similarity = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
          message_arena, nearest_iou_similarity, submessage_arena);
    }
    set_has_nearest_iou_similarity();
    _impl_.region_similarity_.nearest_iou_similarity_ = nearest_iou_similarity;
  }
  // @@protoc_insertion_point(field_set_allocated:second.protos.RegionSimilarityCalculator.nearest_iou_similarity)
}
void RegionSimilarityCalculator::set_allocated_distance_similarity(::second::protos::DistanceSimilarity* distance_similarity) {
  ::PROTOBUF_NAMESPACE_ID::Arena* message_arena = GetArenaForAllocation();
  clear_region_similarity();
  if (distance_similarity) {
    ::PROTOBUF_NAMESPACE_ID::Arena* submessage_arena =
      ::PROTOBUF_NAMESPACE_ID::Arena::InternalGetOwningArena(distance_similarity);
    if (message_arena != submessage_arena) {
      distance_similarity = ::PROTOBUF_NAMESPACE_ID::internal::GetOwnedMessage(
          message_arena, distance_similarity, submessage_arena);
    }
    set_has_distance_similarity();
    _impl_.region_similarity_.distance_similarity_ = distance_similarity;
  }
  // @@protoc_insertion_point(field_set_allocated:second.protos.RegionSimilarityCalculator.distance_similarity)
}
RegionSimilarityCalculator::RegionSimilarityCalculator(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
  SharedCtor(arena, is_message_owned);
  // @@protoc_insertion_point(arena_constructor:second.protos.RegionSimilarityCalculator)
}
RegionSimilarityCalculator::RegionSimilarityCalculator(const RegionSimilarityCalculator& from)
  : ::PROTOBUF_NAMESPACE_ID::Message() {
  RegionSimilarityCalculator* const _this = this; (void)_this;
  new (&_impl_) Impl_{
      decltype(_impl_.region_similarity_){}
    , /*decltype(_impl_._cached_size_)*/{}
    , /*decltype(_impl_._oneof_case_)*/{}};

  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  clear_has_region_similarity();
  switch (from.region_similarity_case()) {
    case kRotateIouSimilarity: {
      _this->_internal_mutable_rotate_iou_similarity()->::second::protos::RotateIouSimilarity::MergeFrom(
          from._internal_rotate_iou_similarity());
      break;
    }
    case kNearestIouSimilarity: {
      _this->_internal_mutable_nearest_iou_similarity()->::second::protos::NearestIouSimilarity::MergeFrom(
          from._internal_nearest_iou_similarity());
      break;
    }
    case kDistanceSimilarity: {
      _this->_internal_mutable_distance_similarity()->::second::protos::DistanceSimilarity::MergeFrom(
          from._internal_distance_similarity());
      break;
    }
    case REGION_SIMILARITY_NOT_SET: {
      break;
    }
  }
  // @@protoc_insertion_point(copy_constructor:second.protos.RegionSimilarityCalculator)
}

inline void RegionSimilarityCalculator::SharedCtor(
    ::_pb::Arena* arena, bool is_message_owned) {
  (void)arena;
  (void)is_message_owned;
  new (&_impl_) Impl_{
      decltype(_impl_.region_similarity_){}
    , /*decltype(_impl_._cached_size_)*/{}
    , /*decltype(_impl_._oneof_case_)*/{}
  };
  clear_has_region_similarity();
}

RegionSimilarityCalculator::~RegionSimilarityCalculator() {
  // @@protoc_insertion_point(destructor:second.protos.RegionSimilarityCalculator)
  if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
  (void)arena;
    return;
  }
  SharedDtor();
}

inline void RegionSimilarityCalculator::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
  if (has_region_similarity()) {
    clear_region_similarity();
  }
}

void RegionSimilarityCalculator::SetCachedSize(int size) const {
  _impl_._cached_size_.Set(size);
}

void RegionSimilarityCalculator::clear_region_similarity() {
// @@protoc_insertion_point(one_of_clear_start:second.protos.RegionSimilarityCalculator)
  switch (region_similarity_case()) {
    case kRotateIouSimilarity: {
      if (GetArenaForAllocation() == nullptr) {
        delete _impl_.region_similarity_.rotate_iou_similarity_;
      }
      break;
    }
    case kNearestIouSimilarity: {
      if (GetArenaForAllocation() == nullptr) {
        delete _impl_.region_similarity_.nearest_iou_similarity_;
      }
      break;
    }
    case kDistanceSimilarity: {
      if (GetArenaForAllocation() == nullptr) {
        delete _impl_.region_similarity_.distance_similarity_;
      }
      break;
    }
    case REGION_SIMILARITY_NOT_SET: {
      break;
    }
  }
  _impl_._oneof_case_[0] = REGION_SIMILARITY_NOT_SET;
}


void RegionSimilarityCalculator::Clear() {
// @@protoc_insertion_point(message_clear_start:second.protos.RegionSimilarityCalculator)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  clear_region_similarity();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* RegionSimilarityCalculator::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::_pbi::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // .second.protos.RotateIouSimilarity rotate_iou_similarity = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) {
          ptr = ctx->ParseMessage(_internal_mutable_rotate_iou_similarity(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // .second.protos.NearestIouSimilarity nearest_iou_similarity = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
          ptr = ctx->ParseMessage(_internal_mutable_nearest_iou_similarity(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // .second.protos.DistanceSimilarity distance_similarity = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) {
          ptr = ctx->ParseMessage(_internal_mutable_distance_similarity(), ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* RegionSimilarityCalculator::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:second.protos.RegionSimilarityCalculator)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  // .second.protos.RotateIouSimilarity rotate_iou_similarity = 1;
  if (_internal_has_rotate_iou_similarity()) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(1, _Internal::rotate_iou_similarity(this),
        _Internal::rotate_iou_similarity(this).GetCachedSize(), target, stream);
  }

  // .second.protos.NearestIouSimilarity nearest_iou_similarity = 2;
  if (_internal_has_nearest_iou_similarity()) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(2, _Internal::nearest_iou_similarity(this),
        _Internal::nearest_iou_similarity(this).GetCachedSize(), target, stream);
  }

  // .second.protos.DistanceSimilarity distance_similarity = 3;
  if (_internal_has_distance_similarity()) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(3, _Internal::distance_similarity(this),
        _Internal::distance_similarity(this).GetCachedSize(), target, stream);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:second.protos.RegionSimilarityCalculator)
  return target;
}

size_t RegionSimilarityCalculator::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:second.protos.RegionSimilarityCalculator)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  switch (region_similarity_case()) {
    // .second.protos.RotateIouSimilarity rotate_iou_similarity = 1;
    case kRotateIouSimilarity: {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *_impl_.region_similarity_.rotate_iou_similarity_);
      break;
    }
    // .second.protos.NearestIouSimilarity nearest_iou_similarity = 2;
    case kNearestIouSimilarity: {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *_impl_.region_similarity_.nearest_iou_similarity_);
      break;
    }
    // .second.protos.DistanceSimilarity distance_similarity = 3;
    case kDistanceSimilarity: {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(
          *_impl_.region_similarity_.distance_similarity_);
      break;
    }
    case REGION_SIMILARITY_NOT_SET: {
      break;
    }
  }
  return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}

const ::PROTOBUF_NAMESPACE_ID::Message::ClassData RegionSimilarityCalculator::_class_data_ = {
    ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck,
    RegionSimilarityCalculator::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*RegionSimilarityCalculator::GetClassData() const { return &_class_data_; }


void RegionSimilarityCalculator::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
  auto* const _this = static_cast<RegionSimilarityCalculator*>(&to_msg);
  auto& from = static_cast<const RegionSimilarityCalculator&>(from_msg);
  // @@protoc_insertion_point(class_specific_merge_from_start:second.protos.RegionSimilarityCalculator)
  GOOGLE_DCHECK_NE(&from, _this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  switch (from.region_similarity_case()) {
    case kRotateIouSimilarity: {
      _this->_internal_mutable_rotate_iou_similarity()->::second::protos::RotateIouSimilarity::MergeFrom(
          from._internal_rotate_iou_similarity());
      break;
    }
    case kNearestIouSimilarity: {
      _this->_internal_mutable_nearest_iou_similarity()->::second::protos::NearestIouSimilarity::MergeFrom(
          from._internal_nearest_iou_similarity());
      break;
    }
    case kDistanceSimilarity: {
      _this->_internal_mutable_distance_similarity()->::second::protos::DistanceSimilarity::MergeFrom(
          from._internal_distance_similarity());
      break;
    }
    case REGION_SIMILARITY_NOT_SET: {
      break;
    }
  }
  _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}

void RegionSimilarityCalculator::CopyFrom(const RegionSimilarityCalculator& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:second.protos.RegionSimilarityCalculator)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool RegionSimilarityCalculator::IsInitialized() const {
  return true;
}

void RegionSimilarityCalculator::InternalSwap(RegionSimilarityCalculator* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  swap(_impl_.region_similarity_, other->_impl_.region_similarity_);
  swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]);
}

::PROTOBUF_NAMESPACE_ID::Metadata RegionSimilarityCalculator::GetMetadata() const {
  return ::_pbi::AssignDescriptors(
      &descriptor_table_second_2fprotos_2fsimilarity_2eproto_getter, &descriptor_table_second_2fprotos_2fsimilarity_2eproto_once,
      file_level_metadata_second_2fprotos_2fsimilarity_2eproto[0]);
}

// ===================================================================

class RotateIouSimilarity::_Internal {
 public:
};

RotateIouSimilarity::RotateIouSimilarity(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) {
  // @@protoc_insertion_point(arena_constructor:second.protos.RotateIouSimilarity)
}
RotateIouSimilarity::RotateIouSimilarity(const RotateIouSimilarity& from)
  : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() {
  RotateIouSimilarity* const _this = this; (void)_this;
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  // @@protoc_insertion_point(copy_constructor:second.protos.RotateIouSimilarity)
}





const ::PROTOBUF_NAMESPACE_ID::Message::ClassData RotateIouSimilarity::_class_data_ = {
    ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl,
    ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl,
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*RotateIouSimilarity::GetClassData() const { return &_class_data_; }







::PROTOBUF_NAMESPACE_ID::Metadata RotateIouSimilarity::GetMetadata() const {
  return ::_pbi::AssignDescriptors(
      &descriptor_table_second_2fprotos_2fsimilarity_2eproto_getter, &descriptor_table_second_2fprotos_2fsimilarity_2eproto_once,
      file_level_metadata_second_2fprotos_2fsimilarity_2eproto[1]);
}

// ===================================================================

class NearestIouSimilarity::_Internal {
 public:
};

NearestIouSimilarity::NearestIouSimilarity(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase(arena, is_message_owned) {
  // @@protoc_insertion_point(arena_constructor:second.protos.NearestIouSimilarity)
}
NearestIouSimilarity::NearestIouSimilarity(const NearestIouSimilarity& from)
  : ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase() {
  NearestIouSimilarity* const _this = this; (void)_this;
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  // @@protoc_insertion_point(copy_constructor:second.protos.NearestIouSimilarity)
}





const ::PROTOBUF_NAMESPACE_ID::Message::ClassData NearestIouSimilarity::_class_data_ = {
    ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::CopyImpl,
    ::PROTOBUF_NAMESPACE_ID::internal::ZeroFieldsBase::MergeImpl,
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*NearestIouSimilarity::GetClassData() const { return &_class_data_; }







::PROTOBUF_NAMESPACE_ID::Metadata NearestIouSimilarity::GetMetadata() const {
  return ::_pbi::AssignDescriptors(
      &descriptor_table_second_2fprotos_2fsimilarity_2eproto_getter, &descriptor_table_second_2fprotos_2fsimilarity_2eproto_once,
      file_level_metadata_second_2fprotos_2fsimilarity_2eproto[2]);
}

// ===================================================================

class DistanceSimilarity::_Internal {
 public:
};

DistanceSimilarity::DistanceSimilarity(::PROTOBUF_NAMESPACE_ID::Arena* arena,
                         bool is_message_owned)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena, is_message_owned) {
  SharedCtor(arena, is_message_owned);
  // @@protoc_insertion_point(arena_constructor:second.protos.DistanceSimilarity)
}
DistanceSimilarity::DistanceSimilarity(const DistanceSimilarity& from)
  : ::PROTOBUF_NAMESPACE_ID::Message() {
  DistanceSimilarity* const _this = this; (void)_this;
  new (&_impl_) Impl_{
      decltype(_impl_.distance_norm_){}
    , decltype(_impl_.with_rotation_){}
    , decltype(_impl_.rotation_alpha_){}
    , /*decltype(_impl_._cached_size_)*/{}};

  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&_impl_.distance_norm_, &from._impl_.distance_norm_,
    static_cast<size_t>(reinterpret_cast<char*>(&_impl_.rotation_alpha_) -
    reinterpret_cast<char*>(&_impl_.distance_norm_)) + sizeof(_impl_.rotation_alpha_));
  // @@protoc_insertion_point(copy_constructor:second.protos.DistanceSimilarity)
}

inline void DistanceSimilarity::SharedCtor(
    ::_pb::Arena* arena, bool is_message_owned) {
  (void)arena;
  (void)is_message_owned;
  new (&_impl_) Impl_{
      decltype(_impl_.distance_norm_){0}
    , decltype(_impl_.with_rotation_){false}
    , decltype(_impl_.rotation_alpha_){0}
    , /*decltype(_impl_._cached_size_)*/{}
  };
}

DistanceSimilarity::~DistanceSimilarity() {
  // @@protoc_insertion_point(destructor:second.protos.DistanceSimilarity)
  if (auto *arena = _internal_metadata_.DeleteReturnArena<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>()) {
  (void)arena;
    return;
  }
  SharedDtor();
}

inline void DistanceSimilarity::SharedDtor() {
  GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
}

void DistanceSimilarity::SetCachedSize(int size) const {
  _impl_._cached_size_.Set(size);
}

void DistanceSimilarity::Clear() {
// @@protoc_insertion_point(message_clear_start:second.protos.DistanceSimilarity)
  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  ::memset(&_impl_.distance_norm_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&_impl_.rotation_alpha_) -
      reinterpret_cast<char*>(&_impl_.distance_norm_)) + sizeof(_impl_.rotation_alpha_));
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* DistanceSimilarity::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  while (!ctx->Done(&ptr)) {
    uint32_t tag;
    ptr = ::_pbi::ReadTag(ptr, &tag);
    switch (tag >> 3) {
      // float distance_norm = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 13)) {
          _impl_.distance_norm_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
          ptr += sizeof(float);
        } else
          goto handle_unusual;
        continue;
      // bool with_rotation = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 16)) {
          _impl_.with_rotation_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else
          goto handle_unusual;
        continue;
      // float rotation_alpha = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 29)) {
          _impl_.rotation_alpha_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
          ptr += sizeof(float);
        } else
          goto handle_unusual;
        continue;
      default:
        goto handle_unusual;
    }  // switch
  handle_unusual:
    if ((tag == 0) || ((tag & 7) == 4)) {
      CHK_(ptr);
      ctx->SetLastTag(tag);
      goto message_done;
    }
    ptr = UnknownFieldParse(
        tag,
        _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
        ptr, ctx);
    CHK_(ptr != nullptr);
  }  // while
message_done:
  return ptr;
failure:
  ptr = nullptr;
  goto message_done;
#undef CHK_
}

uint8_t* DistanceSimilarity::_InternalSerialize(
    uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:second.protos.DistanceSimilarity)
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  // float distance_norm = 1;
  static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size.");
  float tmp_distance_norm = this->_internal_distance_norm();
  uint32_t raw_distance_norm;
  memcpy(&raw_distance_norm, &tmp_distance_norm, sizeof(tmp_distance_norm));
  if (raw_distance_norm != 0) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteFloatToArray(1, this->_internal_distance_norm(), target);
  }

  // bool with_rotation = 2;
  if (this->_internal_with_rotation() != 0) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteBoolToArray(2, this->_internal_with_rotation(), target);
  }

  // float rotation_alpha = 3;
  static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size.");
  float tmp_rotation_alpha = this->_internal_rotation_alpha();
  uint32_t raw_rotation_alpha;
  memcpy(&raw_rotation_alpha, &tmp_rotation_alpha, sizeof(tmp_rotation_alpha));
  if (raw_rotation_alpha != 0) {
    target = stream->EnsureSpace(target);
    target = ::_pbi::WireFormatLite::WriteFloatToArray(3, this->_internal_rotation_alpha(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:second.protos.DistanceSimilarity)
  return target;
}

size_t DistanceSimilarity::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:second.protos.DistanceSimilarity)
  size_t total_size = 0;

  uint32_t cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // float distance_norm = 1;
  static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size.");
  float tmp_distance_norm = this->_internal_distance_norm();
  uint32_t raw_distance_norm;
  memcpy(&raw_distance_norm, &tmp_distance_norm, sizeof(tmp_distance_norm));
  if (raw_distance_norm != 0) {
    total_size += 1 + 4;
  }

  // bool with_rotation = 2;
  if (this->_internal_with_rotation() != 0) {
    total_size += 1 + 1;
  }

  // float rotation_alpha = 3;
  static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size.");
  float tmp_rotation_alpha = this->_internal_rotation_alpha();
  uint32_t raw_rotation_alpha;
  memcpy(&raw_rotation_alpha, &tmp_rotation_alpha, sizeof(tmp_rotation_alpha));
  if (raw_rotation_alpha != 0) {
    total_size += 1 + 4;
  }

  return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_);
}

const ::PROTOBUF_NAMESPACE_ID::Message::ClassData DistanceSimilarity::_class_data_ = {
    ::PROTOBUF_NAMESPACE_ID::Message::CopyWithSourceCheck,
    DistanceSimilarity::MergeImpl
};
const ::PROTOBUF_NAMESPACE_ID::Message::ClassData*DistanceSimilarity::GetClassData() const { return &_class_data_; }


void DistanceSimilarity::MergeImpl(::PROTOBUF_NAMESPACE_ID::Message& to_msg, const ::PROTOBUF_NAMESPACE_ID::Message& from_msg) {
  auto* const _this = static_cast<DistanceSimilarity*>(&to_msg);
  auto& from = static_cast<const DistanceSimilarity&>(from_msg);
  // @@protoc_insertion_point(class_specific_merge_from_start:second.protos.DistanceSimilarity)
  GOOGLE_DCHECK_NE(&from, _this);
  uint32_t cached_has_bits = 0;
  (void) cached_has_bits;

  static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size.");
  float tmp_distance_norm = from._internal_distance_norm();
  uint32_t raw_distance_norm;
  memcpy(&raw_distance_norm, &tmp_distance_norm, sizeof(tmp_distance_norm));
  if (raw_distance_norm != 0) {
    _this->_internal_set_distance_norm(from._internal_distance_norm());
  }
  if (from._internal_with_rotation() != 0) {
    _this->_internal_set_with_rotation(from._internal_with_rotation());
  }
  static_assert(sizeof(uint32_t) == sizeof(float), "Code assumes uint32_t and float are the same size.");
  float tmp_rotation_alpha = from._internal_rotation_alpha();
  uint32_t raw_rotation_alpha;
  memcpy(&raw_rotation_alpha, &tmp_rotation_alpha, sizeof(tmp_rotation_alpha));
  if (raw_rotation_alpha != 0) {
    _this->_internal_set_rotation_alpha(from._internal_rotation_alpha());
  }
  _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
}

void DistanceSimilarity::CopyFrom(const DistanceSimilarity& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:second.protos.DistanceSimilarity)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool DistanceSimilarity::IsInitialized() const {
  return true;
}

void DistanceSimilarity::InternalSwap(DistanceSimilarity* other) {
  using std::swap;
  _internal_metadata_.InternalSwap(&other->_internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(DistanceSimilarity, _impl_.rotation_alpha_)
      + sizeof(DistanceSimilarity::_impl_.rotation_alpha_)
      - PROTOBUF_FIELD_OFFSET(DistanceSimilarity, _impl_.distance_norm_)>(
          reinterpret_cast<char*>(&_impl_.distance_norm_),
          reinterpret_cast<char*>(&other->_impl_.distance_norm_));
}

::PROTOBUF_NAMESPACE_ID::Metadata DistanceSimilarity::GetMetadata() const {
  return ::_pbi::AssignDescriptors(
      &descriptor_table_second_2fprotos_2fsimilarity_2eproto_getter, &descriptor_table_second_2fprotos_2fsimilarity_2eproto_once,
      file_level_metadata_second_2fprotos_2fsimilarity_2eproto[3]);
}

// @@protoc_insertion_point(namespace_scope)
}  // namespace protos
}  // namespace second
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::second::protos::RegionSimilarityCalculator*
Arena::CreateMaybeMessage< ::second::protos::RegionSimilarityCalculator >(Arena* arena) {
  return Arena::CreateMessageInternal< ::second::protos::RegionSimilarityCalculator >(arena);
}
template<> PROTOBUF_NOINLINE ::second::protos::RotateIouSimilarity*
Arena::CreateMaybeMessage< ::second::protos::RotateIouSimilarity >(Arena* arena) {
  return Arena::CreateMessageInternal< ::second::protos::RotateIouSimilarity >(arena);
}
template<> PROTOBUF_NOINLINE ::second::protos::NearestIouSimilarity*
Arena::CreateMaybeMessage< ::second::protos::NearestIouSimilarity >(Arena* arena) {
  return Arena::CreateMessageInternal< ::second::protos::NearestIouSimilarity >(arena);
}
template<> PROTOBUF_NOINLINE ::second::protos::DistanceSimilarity*
Arena::CreateMaybeMessage< ::second::protos::DistanceSimilarity >(Arena* arena) {
  return Arena::CreateMessageInternal< ::second::protos::DistanceSimilarity >(arena);
}
PROTOBUF_NAMESPACE_CLOSE

// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
