#include "services/on_device_model/ml/chrome_ml.h"
#include <memory>
#include <optional>
#include <string_view>
#include "base/base_paths.h"
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/debug/crash_logging.h"
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h"
#include "base/metrics/histogram_functions.h"
#include "base/native_library.h"
#include "base/no_destructor.h"
#include "base/path_service.h"
#include "base/process/process.h"
#include "build/build_config.h"
#include "gpu/config/gpu_info_collector.h"
#include "gpu/config/gpu_util.h"
#include "services/on_device_model/ml/chrome_ml_api.h"
#include "services/on_device_model/ml/gpu_blocklist.h"
#include "third_party/dawn/include/dawn/dawn_proc.h"
#include "third_party/dawn/include/dawn/native/DawnNative.h"
#include "third_party/dawn/include/dawn/webgpu_cpp.h"
#if BUILDFLAG(IS_MAC)
#include "base/apple/bundle_locations.h"
#include "base/apple/foundation_util.h"
#endif
namespace ml {
namespace {
constexpr std::string_view kChromeMLLibraryName = …;
enum class GpuErrorReason { … };
void FatalGpuErrorFn(const char* msg) { … }
void FatalErrorFn(const char* msg) { … }
void RecordExactLinearHistogram(const char* name,
int sample,
int exclusive_max) { … }
void RecordCustomCountsHistogram(const char* name,
int sample,
int min,
int exclusive_max,
size_t buckets) { … }
}
ChromeMLHolder::ChromeMLHolder(base::PassKey<ChromeMLHolder>,
base::ScopedNativeLibrary library,
const ChromeMLAPI* api)
: … { … }
ChromeMLHolder::~ChromeMLHolder() = default;
DISABLE_CFI_DLSYM
std::unique_ptr<ChromeMLHolder> ChromeMLHolder::Create(
const std::optional<std::string>& library_name) { … }
ChromeML::ChromeML(const ChromeMLAPI* api) : … { … }
ChromeML::~ChromeML() = default;
ChromeML* ChromeML::Get(const std::optional<std::string>& library_name) { … }
DISABLE_CFI_DLSYM
std::unique_ptr<ChromeML> ChromeML::Create(
const std::optional<std::string>& library_name) { … }
}