<commit_before>#pragma once

#include <memory>

#include "xchainer/array.h"
#include "xchainer/device.h"
#include "xchainer/scalar.h"

namespace xchainer {

class Backend {
public:
    virtual ~Backend() = default;

    virtual std::shared_ptr<void> Allocate(const Device& device, size_t bytesize) = 0;
    virtual void MemoryCopy(void* dst_ptr, const void* src_ptr, size_t bytesize) = 0;
    virtual std::shared_ptr<void> FromBuffer(const Device& device, const std::shared_ptr<void>& src_ptr, size_t bytesize) = 0;

    virtual void Fill(Array& out, Scalar value) = 0;

    virtual void Add(const Array& lhs, const Array& rhs, Array& out) = 0;
    virtual void Mul(const Array& lhs, const Array& rhs, Array& out) = 0;

    virtual void Synchronize() = 0;
};

}  // namespace xchainer<commit_msg>Comment on Backend member functions<commit_after>#pragma once

#include <memory>

#include "xchainer/array.h"
#include "xchainer/device.h"
#include "xchainer/scalar.h"

namespace xchainer {

class Backend {
public:
    virtual ~Backend() = default;

    // Allocates a memory chunk on the specified device.
    virtual std::shared_ptr<void> Allocate(const Device& device, size_t bytesize) = 0;

    // Copies the data between two memory chunks.
    virtual void MemoryCopy(void* dst_ptr, const void* src_ptr, size_t bytesize) = 0;

    // Creates a data buffer filled with the specified data on the specified device.
    //
    // It may allocate a new memory or return an alias.
    // src_ptr is guaranteed to reside in the main RAM.
    virtual std::shared_ptr<void> FromBuffer(const Device& device, const std::shared_ptr<void>& src_ptr, size_t bytesize) = 0;

    virtual void Fill(Array& out, Scalar value) = 0;

    virtual void Add(const Array& lhs, const Array& rhs, Array& out) = 0;
    virtual void Mul(const Array& lhs, const Array& rhs, Array& out) = 0;

    virtual void Synchronize() = 0;
};

}  // namespace xchainer
{'fraction_non_alphanumeric': 0.10949662688116243, 'fraction_numerical': 0.007265179034769071, 'mean_word_length': 3.956298200514139, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5749375', 'n_tokens_mistral': 636, 'n_tokens_neox': 612, 'n_words': 214}