// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// https://www.w3.org/TR/webnn/#api-mlcontextoptions
// Corresponds to WebNN MLDeviceType enum
// https://www.w3.org/TR/webnn/#enumdef-mldevicetype
enum MLDeviceType {
"cpu",
"gpu",
"npu"
};
enum MLPowerPreference {
// Let the user agent select the most suitable behavior.
"default",
// Prioritizes execution speed over power consumption.
"high-performance",
// Prioritizes power consumption over other considerations such as execution
// speed.
"low-power",
};
dictionary MLContextOptions {
// Specified type of device used for WebNN API.
MLDeviceType deviceType = "cpu";
// Preference as related to power consumption.
MLPowerPreference powerPreference = "default";
// Number of thread to use.
// "0" means the backend can determine it automatically.
//
// TODO(crbug.com/338162119): Figure out why the TFLite XNNPACK delegate
// choosing its own thread count is not resulting in good performance, then
// remove this.
unsigned long numThreads = 0;
};