chromium/components/segmentation_platform/internal/segmentation_ukm_helper.cc

// 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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/segmentation_platform/internal/segmentation_ukm_helper.h"

#include "base/bit_cast.h"
#include "base/metrics/field_trial_params.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/time/clock.h"
#include "base/time/time.h"
#include "components/segmentation_platform/internal/constants.h"
#include "components/segmentation_platform/internal/selection/segmentation_result_prefs.h"
#include "components/segmentation_platform/internal/stats.h"
#include "components/segmentation_platform/public/config.h"
#include "components/segmentation_platform/public/features.h"
#include "components/segmentation_platform/public/local_state_helper.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"

#define CALL_MEMBER_FN(obj, func)
#define ARRAY_SIZE(x)

SegmentationUkmHelper;
SegmentId;
Segmentation_ModelExecution;

namespace segmentation_platform {

namespace {
UkmMemberFn;

const UkmMemberFn kSegmentationUkmInputMethods[] =;

const UkmMemberFn kSegmentationUkmPredictionResultMethods[] =;

const UkmMemberFn kSegmentationUkmOutputMethods[] =;

// 1 out of 100 model execution will be reported.
const int kDefaultModelExecutionSamplingRate =;

int GetModelExecutionSamplingRate() {}

// Helper method to add model prediction results to UKM log.
void AddPredictionResultToUkmModelExecution(
    ukm::builders::Segmentation_ModelExecution* model_execution,
    const std::vector<float>& results) {}

std::string GetDebugString(const ModelProvider::Request& input_tensor,
                           const ModelProvider::Response& outputs) {}

}  // namespace

SegmentationUkmHelper::SegmentationUkmHelper() {}

SegmentationUkmHelper::~SegmentationUkmHelper() = default;

// static
SegmentationUkmHelper* SegmentationUkmHelper::GetInstance() {}

void SegmentationUkmHelper::Initialize() {}

ukm::SourceId SegmentationUkmHelper::RecordModelExecutionResult(
    SegmentId segment_id,
    int64_t model_version,
    const ModelProvider::Request& input_tensor,
    const std::vector<float>& results) {}

ukm::SourceId SegmentationUkmHelper::RecordTrainingData(
    SegmentId segment_id,
    int64_t model_version,
    ukm::SourceId ukm_source_id,
    const ModelProvider::Request& input_tensor,
    const ModelProvider::Response& outputs,
    const std::vector<int>& output_indexes,
    std::optional<proto::PredictionResult> prediction_result,
    std::optional<SelectedSegment> selected_segment) {}

bool SegmentationUkmHelper::AddInputsToUkm(
    ukm::builders::Segmentation_ModelExecution* ukm_builder,
    SegmentId segment_id,
    int64_t model_version,
    const ModelProvider::Request& input_tensor) {}

bool SegmentationUkmHelper::AddOutputsToUkm(
    ukm::builders::Segmentation_ModelExecution* ukm_builder,
    const ModelProvider::Response& outputs,
    const std::vector<int>& output_indexes) {}

bool SegmentationUkmHelper::IsUploadRequested(
    const proto::SegmentInfo& segment_info) const {}

// static
int64_t SegmentationUkmHelper::FloatToInt64(float f) {}

// static
bool SegmentationUkmHelper::AllowedToUploadData(
    base::TimeDelta signal_storage_length,
    base::Clock* clock) {}

}  // namespace segmentation_platform