#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/webnn/coreml/graph_builder_coreml.h"
#include <algorithm>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <string_view>
#include <type_traits>
#include "base/bits.h"
#include "base/containers/fixed_flat_set.h"
#include "base/containers/span.h"
#include "base/containers/span_reader.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/overloaded.h"
#include "base/json/json_file_value_serializer.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/numerics/byte_conversions.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/timer/elapsed_timer.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/types/fixed_array.h"
#include "base/unguessable_token.h"
#include "base/uuid.h"
#include "base/values.h"
#include "mojo/public/cpp/base/big_buffer.h"
#include "services/webnn/public/cpp/context_properties.h"
#include "services/webnn/public/cpp/supported_data_types.h"
#include "services/webnn/public/cpp/webnn_errors.h"
#include "services/webnn/public/mojom/webnn_error.mojom.h"
#include "services/webnn/public/mojom/webnn_graph.mojom.h"
#include "services/webnn/webnn_utils.h"
#include "third_party/coremltools/mlmodel/format/FeatureTypes.pb.h"
#include "third_party/coremltools/mlmodel/format/MIL.pb.h"
#include "third_party/fp16/src/include/fp16.h"
namespace webnn::coreml {
namespace {
constexpr char kWriteModelErrorMessage[] = …;
constexpr char kWriteWeightsErrorMessage[] = …;
const base::FilePath::CharType kMlPackageExtension[] = …);
const base::FilePath::CharType kMlPackageDataDir[] = …);
const base::FilePath::CharType kMlPackageWeightsDir[] = …);
const base::FilePath::CharType kMlPackageWeightsFileName[] = …);
const base::FilePath::CharType kMlPackageModelFileName[] = …);
const base::FilePath::CharType kManifestFileName[] = …);
constexpr char kManifestItemAuthorKey[] = …;
constexpr char kManifestItemAuthorValue[] = …;
constexpr char kManifestItemDescriptionKey[] = …;
constexpr char kManifestModelDescriptionValue[] = …;
constexpr char kManifestWeightsDescriptionValue[] = …;
constexpr char kManifestItemNameKey[] = …;
constexpr char kManifestItemPathKey[] = …;
constexpr char kManifestModelValue[] = …;
constexpr char kManifestWeightsValue[] = …;
constexpr char kManifestItemInfoEntriesKey[] = …;
constexpr char kManifestVersionKey[] = …;
constexpr char kManifestVersionValue[] = …;
constexpr char kManifestModelIdentifierKey[] = …;
constexpr char kInputNamePrefix[] = …;
constexpr char kOutputNamePrefix[] = …;
constexpr char kIntermediateOperandPrefix[] = …;
constexpr char kStringSeparator[] = …;
constexpr char kInternalNamePrefix[] = …;
constexpr char kPlaceholderOuputName[] = …;
constexpr char kOpConstTypeName[] = …;
constexpr char kOpArgminTypeName[] = …;
constexpr char kOpArgmaxTypeName[] = …;
constexpr char kOpBatchNormalizationTypeName[] = …;
constexpr char kOpCastTypeName[] = …;
constexpr char kOpClipTypeName[] = …;
constexpr char kOpConcatTypeName[] = …;
constexpr char kOpConv2dTypeName[] = …;
constexpr char kOpConvTranspose2dTypeName[] = …;
constexpr char kOpEluTypeName[] = …;
constexpr char kOpExpandTypeName[] = …;
constexpr char kOpGatherTypeName[] = …;
constexpr char kOpHardSigmoidTypeName[] = …;
constexpr char kOpInstanceNormalizationTypeName[] = …;
constexpr char kOpLayerNormalizationTypeName[] = …;
constexpr char kOpLeakyReluTypeName[] = …;
constexpr char kOpMatmulTypeName[] = …;
constexpr char kOpPadTypeName[] = …;
constexpr char kOpReluTypeName[] = …;
constexpr char kOpReshapeTypeName[] = …;
constexpr char kOpSigmoidTypeName[] = …;
constexpr char kOpSliceTypeName[] = …;
constexpr char kOpSoftmaxTypeName[] = …;
constexpr char kOpSoftplusTypeName[] = …;
constexpr char kOpSoftsignTypeName[] = …;
constexpr char kOpSplitTypeName[] = …;
constexpr char kOpTanhTypeName[] = …;
constexpr char kOpTransposeTypeName[] = …;
constexpr char kOpWhereTypeName[] = …;
constexpr char kOpAddTypeName[] = …;
constexpr char kOpMultiplyTypeName[] = …;
constexpr char kOpDivideTypeName[] = …;
constexpr char kOpSubtractTypeName[] = …;
constexpr char kOpMaximumTypeName[] = …;
constexpr char kOpMinimumTypeName[] = …;
constexpr char kOpPowerTypeName[] = …;
constexpr char kOpLogicalEqual[] = …;
constexpr char kOpLogicalGreater[] = …;
constexpr char kOpLogicalGreaterEqual[] = …;
constexpr char kOpLogicalLess[] = …;
constexpr char kOpLogicalLessEqual[] = …;
constexpr char kOpLogicalNot[] = …;
constexpr char kOpAbsTypeName[] = …;
constexpr char kOpCeilTypeName[] = …;
constexpr char kOpCosTypeName[] = …;
constexpr char kOpExpTypeName[] = …;
constexpr char kOpFloorTypeName[] = …;
constexpr char kOpIdentityTypeName[] = …;
constexpr char kOpSinTypeName[] = …;
constexpr char kOpTanTypeName[] = …;
constexpr char kOpErfTypeName[] = …;
constexpr char kOpSqrtTypeName[] = …;
constexpr char kOpReciprocalTypeName[] = …;
constexpr char kOpLogTypeName[] = …;
constexpr char kOpAvgPoolTypeName[] = …;
constexpr char kOpL2PoolTypeName[] = …;
constexpr char kOpMaxPoolTypeName[] = …;
constexpr char kOpReduceL1[] = …;
constexpr char kOpReduceL2[] = …;
constexpr char kOpReduceLogSum[] = …;
constexpr char kOpReduceLogSumExp[] = …;
constexpr char kOpReduceMax[] = …;
constexpr char kOpReduceMean[] = …;
constexpr char kOpReduceMin[] = …;
constexpr char kOpReduceProduct[] = …;
constexpr char kOpReduceSum[] = …;
constexpr char kOpReduceSumSquare[] = …;
constexpr char kOpUpsampleBilinearTypeName[] = …;
constexpr char kOpUpsampleNearestNeighborTypeName[] = …;
constexpr char kOpParamAlpha[] = …;
constexpr char kOpParamAxes[] = …;
constexpr char kOpParamAxis[] = …;
constexpr char kOpParamBeta[] = …;
constexpr char kOpParamDataTypeName[] = …;
constexpr char kOpParamEpsilon[] = …;
constexpr char kOpParamGamma[] = …;
constexpr char kOpParamKeepDims[] = …;
constexpr char kOpParamPad[] = …;
constexpr char kOpParamX[] = …;
constexpr char kOpParamY[] = …;
constexpr char kWeightsRelativeFilePath[] = …;
static constexpr auto kFloatDataTypes =
base::MakeFixedFlatSet<CoreML::Specification::MILSpec::DataType>(
{CoreML::Specification::MILSpec::DataType::FLOAT16,
CoreML::Specification::MILSpec::DataType::FLOAT32});
static constexpr auto kFloatsAndInt32DataTypes =
base::MakeFixedFlatSet<CoreML::Specification::MILSpec::DataType>(
{CoreML::Specification::MILSpec::DataType::FLOAT16,
CoreML::Specification::MILSpec::DataType::FLOAT32,
CoreML::Specification::MILSpec::DataType::INT32});
enum class BlobDataType : uint32_t { … };
constexpr uint64_t BlobMetadataSentinel = …;
constexpr uint64_t kWeightAlignment = …;
struct WeightHeader { … };
static_assert …;
struct WeightMetadata { … };
static_assert …;
std::optional<BlobDataType> OperandTypeToDataTypeInWeightFile(
OperandDataType data_type) { … }
CoreML::Specification::MILSpec::DataType OperandTypeToMILDataType(
OperandDataType data_type) { … }
OperandDataType MILDataTypeToOperandType(
CoreML::Specification::MILSpec::DataType mil_data_type) { … }
std::string_view MilDataTypeToString(
CoreML::Specification::MILSpec::DataType mil_data_type) { … }
base::unexpected<mojom::ErrorPtr> NewNotSupportedError(std::string message) { … }
base::unexpected<mojom::ErrorPtr> NewUnknownError(std::string message) { … }
template <typename DataType>
requires internal::IsSupportedTensorType<DataType>
struct MilDataTypeMap;
template <>
struct MilDataTypeMap<int32_t> {
static constexpr CoreML::Specification::MILSpec::DataType value =
CoreML::Specification::MILSpec::DataType::INT32;
};
template <>
struct MilDataTypeMap<Float16> {
static constexpr CoreML::Specification::MILSpec::DataType value =
CoreML::Specification::MILSpec::DataType::FLOAT16;
};
template <>
struct MilDataTypeMap<float> {
static constexpr CoreML::Specification::MILSpec::DataType value =
CoreML::Specification::MILSpec::DataType::FLOAT32;
};
template <>
struct MilDataTypeMap<char> {
static constexpr CoreML::Specification::MILSpec::DataType value =
CoreML::Specification::MILSpec::DataType::STRING;
};
template <>
struct MilDataTypeMap<bool> {
static constexpr CoreML::Specification::MILSpec::DataType value =
CoreML::Specification::MILSpec::DataType::BOOL;
};
template <typename DataType>
requires internal::IsSupportedTensorType<DataType>
void SetTensorValueForImmediateValue(
CoreML::Specification::MILSpec::TensorValue& tensor,
base::span<const DataType> value);
template <>
void SetTensorValueForImmediateValue<Float16>(
CoreML::Specification::MILSpec::TensorValue& tensor,
base::span<const Float16> value) { … }
template <>
void SetTensorValueForImmediateValue<float>(
CoreML::Specification::MILSpec::TensorValue& tensor,
base::span<const float> value) { … }
template <>
void SetTensorValueForImmediateValue<int32_t>(
CoreML::Specification::MILSpec::TensorValue& tensor,
base::span<const int32_t> value) { … }
template <>
void SetTensorValueForImmediateValue<char>(
CoreML::Specification::MILSpec::TensorValue& tensor,
base::span<const char> value) { … }
template <>
void SetTensorValueForImmediateValue<bool>(
CoreML::Specification::MILSpec::TensorValue& tensor,
base::span<const bool> value) { … }
void PopulateValueType(CoreML::Specification::MILSpec::DataType mil_data_type,
base::span<const uint32_t> dimensions,
CoreML::Specification::MILSpec::ValueType& value_type) { … }
void PopulateValueTypeFromOperandInfo(
const GraphBuilderCoreml::OperandInfo& operand_info,
CoreML::Specification::MILSpec::ValueType& value_type) { … }
template <typename DataType>
requires internal::IsSupportedTensorType<DataType>
CoreML::Specification::MILSpec::Value CreateTensorImmediateValue(
base::span<const uint32_t> dimensions,
base::span<const DataType> value) { … }
template <typename DataType>
requires internal::IsSupportedTensorType<DataType>
CoreML::Specification::MILSpec::Value Create1DTensorImmediateValue(
base::span<const DataType> value) { … }
CoreML::Specification::MILSpec::Value CreateStringImmediateValue(
std::string_view value) { … }
template <typename DataType>
requires internal::IsSupportedTensorType<DataType>
CoreML::Specification::MILSpec::Value CreateScalarImmediateValue(
const DataType& value) { … }
void SetInputWithValue(
google::protobuf::Map<std::string,
CoreML::Specification::MILSpec::Argument>& inputs,
std::string_view key,
CoreML::Specification::MILSpec::Value value) {
*inputs[key].add_arguments()->mutable_value() = std::move(value);
}
void SetInputsWithValues(
google::protobuf::Map<std::string,
CoreML::Specification::MILSpec::Argument>& inputs,
std::initializer_list<
std::pair<std::string_view, CoreML::Specification::MILSpec::Value>>
params) {
for (auto param : params) {
SetInputWithValue(inputs, param.first, std::move(param.second));
}
}
void SetInputWithName(
google::protobuf::Map<std::string,
CoreML::Specification::MILSpec::Argument>& inputs,
std::string_view key,
std::string_view name) {
inputs[key].add_arguments()->set_name(std::string(name));
}
std::string SanitizeName(std::string_view name) { … }
CoreML::Specification::MILSpec::Value CreateFloatValue(
CoreML::Specification::MILSpec::DataType mil_data_type,
float value) { … }
}
std::string GetCoreMLNameFromInput(std::string_view input_name,
uint64_t operand_id) { … }
std::string GetCoreMLNameFromOutput(std::string_view output_name,
uint64_t operand_id) { … }
base::expected<std::unique_ptr<GraphBuilderCoreml::Result>, mojom::ErrorPtr>
GraphBuilderCoreml::CreateAndBuild(const mojom::GraphInfo& graph_info,
ContextProperties context_properties,
const base::FilePath& working_directory) { … }
ContextProperties GraphBuilderCoreml::GetContextProperties() { … }
GraphBuilderCoreml::GraphBuilderCoreml(const mojom::GraphInfo& graph_info,
ContextProperties context_properties,
base::FilePath ml_package_dir)
: … { … }
GraphBuilderCoreml::~GraphBuilderCoreml() = default;
[[nodiscard]] base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::BuildCoreMLModel() { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::SerializeModel() { … }
std::unique_ptr<GraphBuilderCoreml::Result>
GraphBuilderCoreml::FinishAndTakeResult() { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::WriteWeightsToFile(
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddPlaceholderInput(
CoreML::Specification::MILSpec::Function& main_function,
CoreML::Specification::MILSpec::Block& block) { … }
[[nodiscard]] base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddInput(
uint64_t input_id,
CoreML::Specification::MILSpec::Function& main_function,
CoreML::Specification::MILSpec::Block& block) { … }
[[nodiscard]] base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOutput(uint64_t output_id) { … }
base::expected<CoreML::Specification::MILSpec::Operation*, mojom::ErrorPtr>
GraphBuilderCoreml::CreateUnaryOperation(
SupportedDataType supported_data_type,
std::string_view op_name,
uint64_t input_operand_id,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block,
std::string_view operand_op_name) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddUnaryOperation(
SupportedDataType supported_data_type,
std::string_view op_name,
uint64_t input_operand_id,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block,
std::string_view operand_op_name) { … }
void GraphBuilderCoreml::AddUnaryOperation(
std::string_view op_name,
uint64_t input_operand_id,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block) { … }
template <typename T>
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddUnaryOperation(
SupportedDataType supported_data_type,
std::string_view op_name,
const T& operation,
CoreML::Specification::MILSpec::Block& block,
std::string_view operand_op_name) { … }
template <typename T>
void GraphBuilderCoreml::AddUnaryOperation(
std::string_view op_name,
const T& operation,
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddUnaryFloatsOperationWithEpsilon(
std::string_view op_name,
std::string_view input_name,
CoreML::Specification::MILSpec::DataType input_mil_data_type,
uint64_t output_operand_id,
float epsilon,
CoreML::Specification::MILSpec::Block& block) { … }
template <typename T>
void GraphBuilderCoreml::AddUnaryFloatsOperationWithEpsilon(
std::string_view op_name,
const T& operation,
float epsilon,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForArgMinMax(
const mojom::ArgMinMax& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForBatchNormalization(
const mojom::BatchNormalization& operation,
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddOperationForCast(
uint64_t input_operand_id,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddOperationForClamp(
const mojom::Clamp& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForConcat(
const mojom::Concat& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForConv2d(
const mojom::Conv2d& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForElementwiseBinary(
uint64_t lhs_operand_id,
std::variant<uint64_t, CoreML::Specification::MILSpec::Value> rhs_operand,
uint64_t output_operand_id,
const mojom::ElementWiseBinary::Kind kind,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForElementwiseUnary(
mojom::ElementWiseUnary::Kind kind,
uint64_t input_operand_id,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForElu(
const mojom::Elu& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForExpand(
const mojom::Expand& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForGather(
const mojom::Gather& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForGemm(
const mojom::Gemm& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForHardSigmoid(
uint64_t input_operand_id,
float alpha,
float beta,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForHardSigmoid(
const mojom::HardSigmoid& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForHardSwish(
const mojom::HardSwish& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForInstanceNormalization(
const mojom::InstanceNormalization& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForLayerNormalization(
const mojom::LayerNormalization& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForLeakyRelu(
const mojom::LeakyRelu& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForLinear(
const mojom::Linear& operation,
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddOperationForMatmul(
uint64_t input_x_operand_id,
uint64_t input_y_operand_id,
bool transpose_x,
bool transpose_y,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddOperationForMatmul(
const mojom::Matmul& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForPad(
const mojom::Pad& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForPool2d(
const mojom::Pool2d& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForReduce(
const mojom::Reduce& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForResample2d(
const mojom::Resample2d& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForReshape(
uint64_t input_operand_id,
uint64_t output_operand_id,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForReshape(
const mojom::Reshape& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForSlice(
const mojom::Slice& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddOperationForSoftmax(
const mojom::Softmax& operation,
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddOperationForSplit(
const mojom::Split& operation,
CoreML::Specification::MILSpec::Block& block) { … }
void GraphBuilderCoreml::AddOperationForTranspose(
const mojom::Transpose& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddOperationForWhere(
const mojom::Where& operation,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::AddConstantImmediateValue(
uint64_t constant_id,
CoreML::Specification::MILSpec::Block& block) { … }
base::expected<void, mojom::ErrorPtr> GraphBuilderCoreml::AddConstantFileValue(
uint64_t constant_id,
uint64_t offset,
CoreML::Specification::MILSpec::Block& block) { … }
const mojom::Operand& GraphBuilderCoreml::GetOperand(
uint64_t operand_id) const { … }
[[nodiscard]] const GraphBuilderCoreml::OperandInfo&
GraphBuilderCoreml::GetOperandInfo(uint64_t operand_id) const { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::PopulateConstantOpFromOperand(
uint64_t constant_id,
CoreML::Specification::MILSpec::Operation& op) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::PopulateFeatureDescription(
uint64_t operand_id,
::CoreML::Specification::FeatureDescription& feature_description) { … }
base::expected<uint64_t, mojom::ErrorPtr>
GraphBuilderCoreml::GenerateInternalOperandInfo(
CoreML::Specification::MILSpec::DataType mil_data_type,
base::span<const uint32_t> dimensions) { … }
void GraphBuilderCoreml::PopulateNamedValueType(
uint64_t operand_id,
CoreML::Specification::MILSpec::NamedValueType& named_value_type) { … }
void GraphBuilderCoreml::PopulateNamedValueType(
std::string_view name,
CoreML::Specification::MILSpec::DataType mil_data_type,
base::span<const uint32_t> dimensions,
CoreML::Specification::MILSpec::NamedValueType& named_value_type) { … }
void GraphBuilderCoreml::PopulateNamedValueTypeForInput(
uint64_t operand_id,
CoreML::Specification::MILSpec::NamedValueType& named_value_type) { … }
void GraphBuilderCoreml::UpdateCoreMLInputInfoMap(uint64_t operand_id) { … }
base::expected<void, mojom::ErrorPtr>
GraphBuilderCoreml::SetupMlPackageDirStructure() { … }
std::string GraphBuilderCoreml::GetCoreMLNameFromOperand(uint64_t operand_id) { … }
GraphBuilderCoreml::OperandInfo::OperandInfo(
std::string name,
base::span<const uint32_t> dimensions,
CoreML::Specification::MILSpec::DataType mil_data_type)
: … { … }
GraphBuilderCoreml::OperandInfo::OperandInfo() = default;
GraphBuilderCoreml::OperandInfo::~OperandInfo() = default;
GraphBuilderCoreml::OperandInfo::OperandInfo(OperandInfo&) = default;
GraphBuilderCoreml::OperandInfo::OperandInfo(OperandInfo&&) = default;
GraphBuilderCoreml::Result::Result(base::FilePath ml_package_dir)
: … { … }
GraphBuilderCoreml::Result::~Result() = default;
const base::FilePath& GraphBuilderCoreml::Result::GetModelFilePath() { … }
const GraphBuilderCoreml::OperandInfo&
GraphBuilderCoreml::Result::GetOperandInfo(uint64_t operand_id) const { … }
}