blob: e03aa328fcaefa4af9d89e2d17949db75059c4bf [file] [log] [blame]
// Copyright 2018 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.
// Datatypes used in the Machine Learning API.
// This module is derived from the Feature proto definition of TensorFlow.
// See /tensorflow/core/example/feature.proto in the TensorFlow code.
// NOTE: This mojom exists in two places and must be kept in sync:
// Chromium: //chromeos/services/machine_learning/public/mojom/
// Chrome OS: src/platform2/ml/mojom/
// Note: Other repos downstream of Chromium might also use this mojom.
// Example: A backwards-compatible mojom change (and corresponding
// implementation change) can be made in Chrome OS first, then replicated to the
// clients (Chromium, other downstream repos) later.
// Use //chromeos/services/machine_learning/public/mojom/roll_mojom.sh to help
// replicate Chrome OS-side changes over to Chromium.
module chromeos.machine_learning.mojom;
struct StringList {
array<string> value;
};
struct FloatList {
array<double> value;
};
struct Int64List {
array<int64> value;
};
// The union of all supported tensor types. Supporting a new type comprises the
// following:
// - Adding a new struct above (e.g. BoolList),
// - Adding this new struct to the union below,
// - Adding template specializations for the new type to
// platform2/ml/tensor_view.{h,cc}.
// - Updating platform2/ml/graph_executor_impl.cc to use a TensorView of the
// new type.
//
// TODO(chromium:836098): add new types (e.g. uint8, bool) as they become
// useful.
union ValueList {
StringList string_list;
FloatList float_list;
Int64List int64_list;
};
// A Tensor is a multi-dimensional array with dimensions `shape`, flattened into
// the one-dimensional array `data`.
// It is used for both the inputs (in the form of a map<string, Tensor>) and
// outputs (in the form of an array<Tensor>) of ML inference.
struct Tensor {
ValueList data;
// Each integer is the size of that dimension.
Int64List shape;
};