Some checks failed
Linux Build / Linux cpu (push) Has been cancelled
Linux Build / Linux cpu-clang (push) Has been cancelled
Linux Build / Linux vulkan (push) Has been cancelled
mac-build / macOS CPU (push) Has been cancelled
Nix Build / Nix (cpu) (push) Has been cancelled
Nix Build / Nix (vulkan) (push) Has been cancelled
windows-build / Windows CPU (push) Has been cancelled
31 lines
792 B
C++
31 lines
792 B
C++
#pragma once
|
|
|
|
#include "engine/models/supertonic/assets.h"
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace engine::models::supertonic {
|
|
|
|
struct SupertonicTextInputs {
|
|
std::vector<int64_t> ids;
|
|
std::vector<float> mask;
|
|
int64_t length = 0;
|
|
};
|
|
|
|
class SupertonicTextTokenizer {
|
|
public:
|
|
explicit SupertonicTextTokenizer(std::shared_ptr<const SupertonicAssets> assets);
|
|
|
|
SupertonicTextInputs encode(const std::string & text, const std::string & language) const;
|
|
|
|
private:
|
|
std::string preprocess(const std::string & text, const std::string & language) const;
|
|
std::vector<uint32_t> utf8_to_codepoints(const std::string & text) const;
|
|
|
|
std::shared_ptr<const SupertonicAssets> assets_;
|
|
};
|
|
|
|
} // namespace engine::models::supertonic
|