<commit_before>#include <string>

#include <Api/KttException.h>
#include <KernelRunner/ComputeLayerData.h>
#include <Utility/StlHelpers.h>

namespace ktt
{

ComputeLayerData::ComputeLayerData(const Kernel& kernel, const KernelConfiguration& configuration) :
    m_Kernel(kernel),
    m_Configuration(configuration),
    m_Duration(0),
    m_Overhead(0)
{
    for (const auto* definition : kernel.GetDefinitions())
    {
        const auto id = definition->GetId();
        m_ComputeData.insert({id, KernelComputeData(kernel, *definition, configuration)});
    }
}

void ComputeLayerData::IncreaseDuration(const Nanoseconds duration)
{
    m_Duration += duration;
}

void ComputeLayerData::IncreaseOverhead(const Nanoseconds overhead)
{
    m_Overhead += overhead;
}

void ComputeLayerData::AddPartialResult(const ComputationResult& result)
{
    m_PartialResults.push_back(result);
}

void ComputeLayerData::AddArgumentOverride(const ArgumentId id, const KernelArgument& argument)
{
    m_ArgumentOverrides.insert({id, argument});
    auto& storedArgument = m_ArgumentOverrides.find(id)->second;

    for (auto& data : m_ComputeData)
    {
        data.second.UpdateArgument(id, storedArgument);
    }
}

void ComputeLayerData::SwapArguments(const KernelDefinitionId id, const ArgumentId first, const ArgumentId second)
{
    if (!ContainsKey(m_ComputeData, id))
    {
        throw KttException("Kernel " + m_Kernel.GetName() + " has no data for definition with id "
            + std::to_string(id));
    }

    m_ComputeData.find(id)->second.SwapArguments(first, second);
}

void ComputeLayerData::ChangeArguments(const KernelDefinitionId id, std::vector<KernelArgument*>& arguments)
{
    if (!ContainsKey(m_ComputeData, id))<commit_msg>* Fixed updating of scalar and local kernel arguments through compute interface<commit_after>#include <string>

#include <Api/KttException.h>
#include <KernelRunner/ComputeLayerData.h>
#include <Utility/StlHelpers.h>

namespace ktt
{

ComputeLayerData::ComputeLayerData(const Kernel& kernel, const KernelConfiguration& configuration) :
    m_Kernel(kernel),
    m_Configuration(configuration),
    m_Duration(0),
    m_Overhead(0)
{
    for (const auto* definition : kernel.GetDefinitions())
    {
        const auto id = definition->GetId();
        m_ComputeData.insert({id, KernelComputeData(kernel, *definition, configuration)});
    }
}

void ComputeLayerData::IncreaseDuration(const Nanoseconds duration)
{
    m_Duration += duration;
}

void ComputeLayerData::IncreaseOverhead(const Nanoseconds overhead)
{
    m_Overhead += overhead;
}

void ComputeLayerData::AddPartialResult(const ComputationResult& result)
{
    m_PartialResults.push_back(result);
}

void ComputeLayerData::AddArgumentOverride(const ArgumentId id, const KernelArgument& argument)
{
    m_ArgumentOverrides.erase(id);
    auto pair = m_ArgumentOverrides.insert({id, argument});

    for (auto& data : m_ComputeData)
    {
        data.second.UpdateArgument(id, pair.first->second);
    }
}

void ComputeLayerData::SwapArguments(const KernelDefinitionId id, const ArgumentId first, const ArgumentId second)
{
    if (!ContainsKey(m_ComputeData, id))
    {
        throw KttException("Kernel " + m_Kernel.GetName() + " has no data for definition with id "
            + std::to_string(id));
    }

    m_ComputeData.find(id)->second.SwapArguments(first, second);
}

void ComputeLayerData::ChangeArguments(const KernelDefinitionId id, std::vector<KernelArgument*>& arguments)
{
    if (!ContainsKey(m_ComputeData, id))
{'fraction_non_alphanumeric': 0.11063950198075835, 'fraction_numerical': 0.0011318619128466328, 'mean_word_length': 4.981387478849408, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4319210', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1069, 'n_words': 216}