#include "services/on_device_model/on_device_model_service.h"
#include <queue>
#include <vector>
#include "base/metrics/histogram_functions.h"
#include "base/not_fatal_until.h"
#include "base/timer/elapsed_timer.h"
#include "base/uuid.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "services/on_device_model/ml/on_device_model_executor.h"
#include "services/on_device_model/ml/on_device_model_internal.h"
#if !defined(ENABLE_ML_INTERNAL)
#include "services/on_device_model/fake/on_device_model_fake.h"
#endif
namespace on_device_model {
namespace {
class ModelWrapper;
class SessionWrapper final : public mojom::Session { … };
class ModelWrapper final : public mojom::OnDeviceModel { … };
void SessionWrapper::AddContext(
mojom::InputOptionsPtr input,
mojo::PendingRemote<mojom::ContextClient> client) { … }
void SessionWrapper::Execute(
mojom::InputOptionsPtr input,
mojo::PendingRemote<mojom::StreamingResponder> response) { … }
void SessionWrapper::GetSizeInTokens(const std::string& text,
GetSizeInTokensCallback callback) { … }
void SessionWrapper::Score(const std::string& text, ScoreCallback callback) { … }
void SessionWrapper::Clone(mojo::PendingReceiver<mojom::Session> session) { … }
void SessionWrapper::CloneInternal(
mojo::PendingReceiver<mojom::Session> session) { … }
const ml::OnDeviceModelInternalImpl* DefaultImpl() { … }
}
OnDeviceModelService::OnDeviceModelService(
mojo::PendingReceiver<mojom::OnDeviceModelService> receiver)
: … { … }
OnDeviceModelService::OnDeviceModelService(
mojo::PendingReceiver<mojom::OnDeviceModelService> receiver,
const ml::OnDeviceModelInternalImpl* impl)
: … { … }
OnDeviceModelService::~OnDeviceModelService() = default;
void OnDeviceModelService::LoadModel(
mojom::LoadModelParamsPtr params,
mojo::PendingReceiver<mojom::OnDeviceModel> model,
LoadModelCallback callback) { … }
void OnDeviceModelService::GetEstimatedPerformanceClass(
GetEstimatedPerformanceClassCallback callback) { … }
void OnDeviceModelService::DeleteModel(
base::WeakPtr<mojom::OnDeviceModel> model) { … }
}