oa::ByteEncoder

BYTE ENCODER - Raw bytes to tensor and back

Static Public Methods

static oa::Vector<oa::U8> oa::ByteEncoder::decode(const oa::Matrix & inLogits)
static oa::String oa::ByteEncoder::decodeText(const oa::Matrix & inLogits)
static oa::Matrix oa::ByteEncoder::encode(oa::Span<const oa::U8> inBytes)
static oa::Matrix oa::ByteEncoder::encodeAudio(oa::Span<const oa::U8> inSamples, oa::I32 inSampleRate, oa::I32 inChannels)
static oa::Matrix oa::ByteEncoder::encodeBatched(oa::Span<const oa::U8> inBytes)
static oa::Matrix oa::ByteEncoder::encodeImage(oa::Span<const oa::U8> inPixels, oa::I32 inWidth, oa::I32 inHeight, oa::I32 inChannels)
static oa::Matrix oa::ByteEncoder::encodeText(oa::StringView inText)
static Vector<U8> oa::ByteEncoder::sample(const Matrix & inLogits, F32 inTemperature = 1.0F, F32 inTopP = 0.9F)

Public Method Documentation

static oa::Vector<oa::U8> oa::ByteEncoder::decode( const oa::Matrix & inLogits )
Decode logits [seq_len, 256] back to bytes (argmax)

Parameters

inLogits
const oa::Matrix &

Returns

oa::Vector<oa::U8>

The declared return value.

static oa::String oa::ByteEncoder::decodeText( const oa::Matrix & inLogits )
Decode bytes back to string

Parameters

inLogits
const oa::Matrix &

Returns

oa::String

The declared return value.

static oa::Matrix oa::ByteEncoder::encode( oa::Span<const oa::U8> inBytes )
Encode raw bytes to tensor [seq_len] of UInt8

Parameters

inBytes
oa::Span<const oa::U8>

Returns

oa::Matrix

The declared return value.

static oa::Matrix oa::ByteEncoder::encodeAudio( oa::Span<const oa::U8> inSamples, oa::I32 inSampleRate, oa::I32 inChannels )
Audio: raw sample bytes

Parameters

inSamples
oa::Span<const oa::U8>

inSampleRate
oa::I32

inChannels
oa::I32

Returns

oa::Matrix

The declared return value.

static oa::Matrix oa::ByteEncoder::encodeBatched( oa::Span<const oa::U8> inBytes )
Encode with batch dimension [1, seq_len]

Parameters

inBytes
oa::Span<const oa::U8>

Returns

oa::Matrix

The declared return value.

static oa::Matrix oa::ByteEncoder::encodeImage( oa::Span<const oa::U8> inPixels, oa::I32 inWidth, oa::I32 inHeight, oa::I32 inChannels )
Image: raw pixel bytes [H * W * C]

Parameters

inPixels
oa::Span<const oa::U8>

inWidth
oa::I32

inHeight
oa::I32

inChannels
oa::I32

Returns

oa::Matrix

The declared return value.

static oa::Matrix oa::ByteEncoder::encodeText( oa::StringView inText )
text: just cast string bytes directly

Parameters

inText
oa::StringView

Returns

oa::Matrix

The declared return value.

static Vector<U8> oa::ByteEncoder::sample( const Matrix & inLogits, F32 inTemperature = 1.0F, F32 inTopP = 0.9F )
Decode with temperature sampling

Parameters

inLogits
const Matrix &

inTemperature
F32

Default: 1.0F

inTopP
F32

Default: 0.9F

Returns

Vector<U8>

The declared return value.