| // chromeos/services/machine_learning/public/mojom/tensor.mojom-shared.h is auto generated by mojom_bindings_generator.py, do not edit |
| |
| // Copyright 2016 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_MOJOM_TENSOR_MOJOM_SHARED_H_ |
| #define CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_MOJOM_TENSOR_MOJOM_SHARED_H_ |
| |
| #include <stdint.h> |
| |
| #include <functional> |
| #include <iosfwd> |
| #include <type_traits> |
| #include <utility> |
| #include "mojo/public/cpp/bindings/array_data_view.h" |
| #include "mojo/public/cpp/bindings/enum_traits.h" |
| #include "mojo/public/cpp/bindings/interface_data_view.h" |
| #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| #include "mojo/public/cpp/bindings/lib/serialization.h" |
| #include "mojo/public/cpp/bindings/map_data_view.h" |
| #include "mojo/public/cpp/bindings/string_data_view.h" |
| |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" |
| |
| #include "chromeos/services/machine_learning/public/mojom/tensor.mojom-shared-internal.h" |
| |
| |
| |
| #include "base/component_export.h" |
| |
| #ifdef KYTHE_IS_RUNNING |
| #pragma kythe_inline_metadata "Metadata comment" |
| #endif |
| |
| |
| namespace chromeos { |
| namespace machine_learning { |
| namespace mojom { |
| class StringListDataView; |
| |
| class FloatListDataView; |
| |
| class Int64ListDataView; |
| |
| class TensorDataView; |
| |
| class ValueListDataView; |
| |
| |
| } // namespace mojom |
| } // namespace machine_learning |
| } // namespace chromeos |
| |
| namespace mojo { |
| namespace internal { |
| |
| template <> |
| struct MojomTypeTraits<::chromeos::machine_learning::mojom::StringListDataView> { |
| using Data = ::chromeos::machine_learning::mojom::internal::StringList_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| template <> |
| struct MojomTypeTraits<::chromeos::machine_learning::mojom::FloatListDataView> { |
| using Data = ::chromeos::machine_learning::mojom::internal::FloatList_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| template <> |
| struct MojomTypeTraits<::chromeos::machine_learning::mojom::Int64ListDataView> { |
| using Data = ::chromeos::machine_learning::mojom::internal::Int64List_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| template <> |
| struct MojomTypeTraits<::chromeos::machine_learning::mojom::TensorDataView> { |
| using Data = ::chromeos::machine_learning::mojom::internal::Tensor_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| template <> |
| struct MojomTypeTraits<::chromeos::machine_learning::mojom::ValueListDataView> { |
| using Data = ::chromeos::machine_learning::mojom::internal::ValueList_Data; |
| using DataAsArrayElement = Data; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion; |
| }; |
| |
| } // namespace internal |
| } // namespace mojo |
| |
| |
| namespace chromeos { |
| namespace machine_learning { |
| namespace mojom { |
| |
| |
| class StringListDataView { |
| public: |
| StringListDataView() = default; |
| |
| StringListDataView( |
| internal::StringList_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { return !data_; } |
| inline void GetValueDataView( |
| mojo::ArrayDataView<mojo::StringDataView>* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadValue(UserType* output) { |
| |
| auto* pointer = data_->value.Get(); |
| return mojo::internal::Deserialize<mojo::ArrayDataView<mojo::StringDataView>>( |
| pointer, output, message_); |
| } |
| private: |
| internal::StringList_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| |
| class FloatListDataView { |
| public: |
| FloatListDataView() = default; |
| |
| FloatListDataView( |
| internal::FloatList_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { return !data_; } |
| inline void GetValueDataView( |
| mojo::ArrayDataView<double>* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadValue(UserType* output) { |
| |
| auto* pointer = data_->value.Get(); |
| return mojo::internal::Deserialize<mojo::ArrayDataView<double>>( |
| pointer, output, message_); |
| } |
| private: |
| internal::FloatList_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| |
| class Int64ListDataView { |
| public: |
| Int64ListDataView() = default; |
| |
| Int64ListDataView( |
| internal::Int64List_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { return !data_; } |
| inline void GetValueDataView( |
| mojo::ArrayDataView<int64_t>* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadValue(UserType* output) { |
| |
| auto* pointer = data_->value.Get(); |
| return mojo::internal::Deserialize<mojo::ArrayDataView<int64_t>>( |
| pointer, output, message_); |
| } |
| private: |
| internal::Int64List_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| |
| class TensorDataView { |
| public: |
| TensorDataView() = default; |
| |
| TensorDataView( |
| internal::Tensor_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { return !data_; } |
| inline void GetDataDataView( |
| ValueListDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadData(UserType* output) { |
| |
| auto* pointer = !data_->data.is_null() ? &data_->data : nullptr; |
| return mojo::internal::Deserialize<::chromeos::machine_learning::mojom::ValueListDataView>( |
| pointer, output, message_); |
| } |
| inline void GetShapeDataView( |
| Int64ListDataView* output); |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadShape(UserType* output) { |
| |
| auto* pointer = data_->shape.Get(); |
| return mojo::internal::Deserialize<::chromeos::machine_learning::mojom::Int64ListDataView>( |
| pointer, output, message_); |
| } |
| private: |
| internal::Tensor_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| |
| class ValueListDataView { |
| public: |
| using Tag = internal::ValueList_Data::ValueList_Tag; |
| |
| ValueListDataView() = default; |
| |
| ValueListDataView( |
| internal::ValueList_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { |
| // For inlined unions, |data_| is always non-null. In that case we need to |
| // check |data_->is_null()|. |
| return !data_ || data_->is_null(); |
| } |
| |
| Tag tag() const { return data_->tag; } |
| bool is_string_list() const { return data_->tag == Tag::kStringList; } |
| inline void GetStringListDataView( |
| StringListDataView* output) const; |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadStringList(UserType* output) const { |
| |
| CHECK(is_string_list()); |
| return mojo::internal::Deserialize<::chromeos::machine_learning::mojom::StringListDataView>( |
| data_->data.f_string_list.Get(), output, message_); |
| } |
| bool is_float_list() const { return data_->tag == Tag::kFloatList; } |
| inline void GetFloatListDataView( |
| FloatListDataView* output) const; |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadFloatList(UserType* output) const { |
| |
| CHECK(is_float_list()); |
| return mojo::internal::Deserialize<::chromeos::machine_learning::mojom::FloatListDataView>( |
| data_->data.f_float_list.Get(), output, message_); |
| } |
| bool is_int64_list() const { return data_->tag == Tag::kInt64List; } |
| inline void GetInt64ListDataView( |
| Int64ListDataView* output) const; |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadInt64List(UserType* output) const { |
| |
| CHECK(is_int64_list()); |
| return mojo::internal::Deserialize<::chromeos::machine_learning::mojom::Int64ListDataView>( |
| data_->data.f_int64_list.Get(), output, message_); |
| } |
| |
| private: |
| internal::ValueList_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| |
| } // namespace mojom |
| } // namespace machine_learning |
| } // namespace chromeos |
| |
| namespace std { |
| |
| } // namespace std |
| |
| namespace mojo { |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::chromeos::machine_learning::mojom::StringListDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::chromeos::machine_learning::mojom::StringListDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::chromeos::machine_learning::mojom::internal::StringList_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| decltype(Traits::value(input)) in_value = Traits::value(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->value)::BaseType> |
| value_fragment(fragment.message()); |
| const mojo::internal::ContainerValidateParams value_validate_params( |
| 0, false, new mojo::internal::ContainerValidateParams(0, false, nullptr)); |
| mojo::internal::Serialize<mojo::ArrayDataView<mojo::StringDataView>>( |
| in_value, value_fragment, &value_validate_params); |
| fragment->value.Set( |
| value_fragment.is_null() ? nullptr : value_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->value.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null value in StringList struct"); |
| } |
| |
| static bool Deserialize(::chromeos::machine_learning::mojom::internal::StringList_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::chromeos::machine_learning::mojom::StringListDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::chromeos::machine_learning::mojom::FloatListDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::chromeos::machine_learning::mojom::FloatListDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::chromeos::machine_learning::mojom::internal::FloatList_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| decltype(Traits::value(input)) in_value = Traits::value(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->value)::BaseType> |
| value_fragment(fragment.message()); |
| const mojo::internal::ContainerValidateParams value_validate_params( |
| 0, false, nullptr); |
| mojo::internal::Serialize<mojo::ArrayDataView<double>>( |
| in_value, value_fragment, &value_validate_params); |
| fragment->value.Set( |
| value_fragment.is_null() ? nullptr : value_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->value.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null value in FloatList struct"); |
| } |
| |
| static bool Deserialize(::chromeos::machine_learning::mojom::internal::FloatList_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::chromeos::machine_learning::mojom::FloatListDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::chromeos::machine_learning::mojom::Int64ListDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::chromeos::machine_learning::mojom::Int64ListDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::chromeos::machine_learning::mojom::internal::Int64List_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| decltype(Traits::value(input)) in_value = Traits::value(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->value)::BaseType> |
| value_fragment(fragment.message()); |
| const mojo::internal::ContainerValidateParams value_validate_params( |
| 0, false, nullptr); |
| mojo::internal::Serialize<mojo::ArrayDataView<int64_t>>( |
| in_value, value_fragment, &value_validate_params); |
| fragment->value.Set( |
| value_fragment.is_null() ? nullptr : value_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->value.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null value in Int64List struct"); |
| } |
| |
| static bool Deserialize(::chromeos::machine_learning::mojom::internal::Int64List_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::chromeos::machine_learning::mojom::Int64ListDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::chromeos::machine_learning::mojom::TensorDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::chromeos::machine_learning::mojom::TensorDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::chromeos::machine_learning::mojom::internal::Tensor_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| decltype(Traits::data(input)) in_data = Traits::data(input); |
| mojo::internal::MessageFragment<decltype(fragment->data)> |
| data_fragment(fragment.message()); |
| data_fragment.Claim(&fragment->data); |
| mojo::internal::Serialize<::chromeos::machine_learning::mojom::ValueListDataView>( |
| in_data, data_fragment, true); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->data.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null data in Tensor struct"); |
| decltype(Traits::shape(input)) in_shape = Traits::shape(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->shape)::BaseType> shape_fragment( |
| fragment.message()); |
| mojo::internal::Serialize<::chromeos::machine_learning::mojom::Int64ListDataView>( |
| in_shape, shape_fragment); |
| fragment->shape.Set( |
| shape_fragment.is_null() ? nullptr : shape_fragment.data()); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| fragment->shape.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null shape in Tensor struct"); |
| } |
| |
| static bool Deserialize(::chromeos::machine_learning::mojom::internal::Tensor_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::chromeos::machine_learning::mojom::TensorDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::chromeos::machine_learning::mojom::ValueListDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = UnionTraits<::chromeos::machine_learning::mojom::ValueListDataView, UserType>; |
| |
| static void Serialize(MaybeConstUserType& input, |
| MessageFragment<::chromeos::machine_learning::mojom::internal::ValueList_Data>& fragment, |
| bool inlined) { |
| if (CallIsNullIfExists<Traits>(input)) { |
| if (inlined) |
| fragment->set_null(); |
| return; |
| } |
| |
| if (!inlined) |
| fragment.Allocate(); |
| |
| // TODO(azani): Handle unknown and objects. |
| // Set the not-null flag. |
| fragment->size = kUnionDataSize; |
| fragment->tag = Traits::GetTag(input); |
| switch (fragment->tag) { |
| case ::chromeos::machine_learning::mojom::ValueListDataView::Tag::kStringList: { |
| decltype(Traits::string_list(input)) |
| in_string_list = Traits::string_list(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->data.f_string_list)::BaseType> |
| value_fragment(fragment.message()); |
| mojo::internal::Serialize<::chromeos::machine_learning::mojom::StringListDataView>( |
| in_string_list, value_fragment); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| value_fragment.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null string_list in ValueList union"); |
| fragment->data.f_string_list.Set( |
| value_fragment.is_null() ? nullptr : value_fragment.data()); |
| break; |
| } |
| case ::chromeos::machine_learning::mojom::ValueListDataView::Tag::kFloatList: { |
| decltype(Traits::float_list(input)) |
| in_float_list = Traits::float_list(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->data.f_float_list)::BaseType> |
| value_fragment(fragment.message()); |
| mojo::internal::Serialize<::chromeos::machine_learning::mojom::FloatListDataView>( |
| in_float_list, value_fragment); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| value_fragment.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null float_list in ValueList union"); |
| fragment->data.f_float_list.Set( |
| value_fragment.is_null() ? nullptr : value_fragment.data()); |
| break; |
| } |
| case ::chromeos::machine_learning::mojom::ValueListDataView::Tag::kInt64List: { |
| decltype(Traits::int64_list(input)) |
| in_int64_list = Traits::int64_list(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->data.f_int64_list)::BaseType> |
| value_fragment(fragment.message()); |
| mojo::internal::Serialize<::chromeos::machine_learning::mojom::Int64ListDataView>( |
| in_int64_list, value_fragment); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| value_fragment.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null int64_list in ValueList union"); |
| fragment->data.f_int64_list.Set( |
| value_fragment.is_null() ? nullptr : value_fragment.data()); |
| break; |
| } |
| } |
| } |
| |
| static bool Deserialize(::chromeos::machine_learning::mojom::internal::ValueList_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input || input->is_null()) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::chromeos::machine_learning::mojom::ValueListDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| } // namespace mojo |
| |
| |
| namespace chromeos { |
| namespace machine_learning { |
| namespace mojom { |
| |
| inline void StringListDataView::GetValueDataView( |
| mojo::ArrayDataView<mojo::StringDataView>* output) { |
| auto pointer = data_->value.Get(); |
| *output = mojo::ArrayDataView<mojo::StringDataView>(pointer, message_); |
| } |
| |
| |
| inline void FloatListDataView::GetValueDataView( |
| mojo::ArrayDataView<double>* output) { |
| auto pointer = data_->value.Get(); |
| *output = mojo::ArrayDataView<double>(pointer, message_); |
| } |
| |
| |
| inline void Int64ListDataView::GetValueDataView( |
| mojo::ArrayDataView<int64_t>* output) { |
| auto pointer = data_->value.Get(); |
| *output = mojo::ArrayDataView<int64_t>(pointer, message_); |
| } |
| |
| |
| inline void TensorDataView::GetDataDataView( |
| ValueListDataView* output) { |
| auto pointer = &data_->data; |
| *output = ValueListDataView(pointer, message_); |
| } |
| inline void TensorDataView::GetShapeDataView( |
| Int64ListDataView* output) { |
| auto pointer = data_->shape.Get(); |
| *output = Int64ListDataView(pointer, message_); |
| } |
| |
| |
| inline void ValueListDataView::GetStringListDataView( |
| StringListDataView* output) const { |
| CHECK(is_string_list()); |
| *output = StringListDataView(data_->data.f_string_list.Get(), message_); |
| } |
| inline void ValueListDataView::GetFloatListDataView( |
| FloatListDataView* output) const { |
| CHECK(is_float_list()); |
| *output = FloatListDataView(data_->data.f_float_list.Get(), message_); |
| } |
| inline void ValueListDataView::GetInt64ListDataView( |
| Int64ListDataView* output) const { |
| CHECK(is_int64_list()); |
| *output = Int64ListDataView(data_->data.f_int64_list.Get(), message_); |
| } |
| |
| |
| } // namespace mojom |
| } // namespace machine_learning |
| } // namespace chromeos |
| |
| // Declare TraceFormatTraits for enums, which should be defined in ::perfetto |
| // namespace. |
| |
| #endif // CHROMEOS_SERVICES_MACHINE_LEARNING_PUBLIC_MOJOM_TENSOR_MOJOM_SHARED_H_ |
| |
| /* Metadata comment |
| eyJtZXRhIjogW10sICJ0eXBlIjogImt5dGhlMCJ9 |
| */ |