// Copyright 2024 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef SERVICES_WEBNN_TFLITE_GRAPH_BUILDER_TFLITE_H_ #define SERVICES_WEBNN_TFLITE_GRAPH_BUILDER_TFLITE_H_ #include <concepts> #include <cstdint> #include <map> #include <string> #include <vector> #include "base/containers/flat_map.h" #include "base/containers/span.h" #include "base/memory/raw_ref.h" #include "base/memory/stack_allocated.h" #include "base/types/expected.h" #include "mojo/public/cpp/base/big_buffer.h" #include "services/webnn/public/cpp/context_properties.h" #include "services/webnn/public/mojom/webnn_context_provider.mojom-forward.h" #include "services/webnn/public/mojom/webnn_graph.mojom-forward.h" #include "third_party/flatbuffers/src/include/flatbuffers/flatbuffers.h" #include "third_party/tflite/src/tensorflow/lite/schema/schema_generated.h" namespace webnn::tflite { namespace internal { // Methods which take a generic numerical type as input (e.g. uint32_t) and // expect to serialize the data as a TFLite tensor (e.g. // ::tflite::TensorType_UINT32) may use the `IsSupportedTensorType` concept to // enforce that the data type maps to a supported TFLite tensor type. // The list of supported data types may be expanded as needed. IsAnyOf; IsSupportedTensorType; } // namespace internal // This class converts WebNN graph to tflite model and persist into FlatBuffer. // The schema_generated.h file defines the format for each data structure to // serialize. // // The instances of the class may not be allocated on the heap, but as a member // variable of a non-stack-allocated class and be single-use per conversion. class GraphBuilderTflite final { … }; } // namespace webnn::tflite #endif // SERVICES_WEBNN_TFLITE_GRAPH_BUILDER_TFLITE_H_