MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Yantra::TensorKernels Namespace Reference

Namespaces

namespace  detail

Classes

struct  AddPC
 Push constants of nn_add. More...
struct  AttentionMixPC
 Push constants of nn_attention_mix. More...
struct  AttentionScoresPC
 Push constants of nn_attention_scores. More...
struct  Conv1d
 One convolution layer over [batch, c_in, t_in], with weights [c_out, c_in, kernel]. More...
struct  Conv1dPC
 Push constants of nn_conv1d. More...
struct  FrameAudioPC
 Push constants of nn_frame_audio. More...
struct  GroupedConv1d
 One grouped convolution layer over [batch, c_in, t_in], with weights [c_out, c_in / groups, kernel]. More...
struct  GroupedConv1dPC
 Push constants of nn_conv1d_grouped. More...
struct  LstmPC
 Push constants of nn_lstm_sequence. More...
struct  MagnitudePC
 Push constants of nn_magnitude. More...
struct  NormalizePC
 Push constants of nn_normalize. More...
struct  PackedWeights
 The required tensors as float32 in one run, in the order they were required. More...
struct  SoftmaxPC
 Push constants of nn_softmax. More...
struct  TensorRequirement
 One tensor a network needs. More...

Enumerations

enum class  Activation : uint8_t { None , Relu , Sigmoid , Gelu }
 Output activation of a layer. More...
enum class  NormAffine : uint8_t { None , Along , Outer }
 Which index selects the weight and bias applied after a normalisation. More...

Functions

DependencyStage add_stage (uint64_t a, uint64_t b, uint64_t dst, uint32_t count)
 One nn_add dispatch: the element-wise sum of two sequences of count floats.
DependencyStage attention_mix_stage (uint64_t weights, uint64_t v, uint64_t dst, uint32_t heads, uint32_t dim, uint32_t time)
 One nn_attention_mix dispatch: the values of every position mixed by each query's attention weights.
DependencyStage attention_scores_stage (uint64_t q, uint64_t k, uint64_t scores, uint32_t heads, uint32_t dim, uint32_t time, float scale)
 One nn_attention_scores dispatch: scale times the dot product of every query with every key, per head.
std::string check_tensors (const Kakshya::TensorSet &weights, std::span< const TensorRequirement > required)
 Whether a set holds every required tensor with the required shape.
uint32_t conv1d_length (const Conv1d &layer, uint32_t t_in)
 Output length of a convolution, 0 when the window does not fit the padded input.
DependencyStage conv1d_stage (const Conv1d &layer, uint64_t src, uint64_t weights, uint64_t bias, uint64_t dst, uint32_t batch, uint32_t t_in)
 One nn_conv1d dispatch: [batch, c_in, t_in] to [batch, c_out, conv1d_length].
constexpr uint32_t frame_audio_length (uint32_t chunk_size, uint32_t context, uint32_t pad)
 Length of one frame nn_frame_audio writes.
DependencyStage frame_audio_stage (uint64_t samples, uint64_t frames, uint32_t chunks, uint32_t chunk_size, uint32_t context, uint32_t pad)
 One nn_frame_audio dispatch: cut a sample stream into overlapping frames, reflect padded on the right.
uint32_t grouped_conv1d_length (const GroupedConv1d &layer, uint32_t t_in)
 Output length of a grouped convolution after its trim, 0 when nothing is left.
DependencyStage grouped_conv1d_stage (const GroupedConv1d &layer, uint64_t src, uint64_t weights, uint64_t bias, uint64_t dst, uint32_t batch, uint32_t t_in)
 One nn_conv1d_grouped dispatch: [batch, c_in, t_in] to [batch, c_out, grouped_conv1d_length].
DependencyStage lstm_sequence_stage (uint64_t x, uint64_t w_ih, uint64_t w_hh, uint64_t b_ih, uint64_t b_hh, uint64_t state, uint64_t hs, uint32_t steps, uint32_t hidden)
 One nn_lstm_sequence dispatch: an LSTM cell over a whole sequence in one workgroup.
DependencyStage magnitude_stage (uint64_t src, uint64_t dst, uint32_t batch, uint32_t channels, uint32_t time)
 One nn_magnitude dispatch: sqrt(re^2 + im^2) of a complex signal stored as two channel halves.
DependencyStage normalize_apply_stage (uint64_t src, uint64_t stats, uint64_t weight, uint64_t bias, uint64_t dst, uint32_t outer, uint32_t extent, uint32_t inner, NormAffine affine, Activation activation=Activation::None)
 The nn_normalize dispatch that writes (x - mean) * scale from the measures of normalize_stats_stage.
DependencyStage normalize_stats_stage (uint64_t src, uint64_t stats, uint32_t outer, uint32_t extent, uint32_t inner, float epsilon)
 The nn_normalize dispatch that measures every row of a tensor [outer, extent, inner] along extent.
std::expected< PackedWeights, std::string > pack_weights (const Kakshya::TensorSet &weights, std::span< const TensorRequirement > required)
 Convert the required tensors to float32 and lay them out in the order of required.
DependencyStage softmax_stage (uint64_t data, uint32_t outer, uint32_t extent, uint32_t inner)
 One nn_softmax dispatch: softmax of a tensor [outer, extent, inner] along extent, in place.
void upload_packed_weights (GpuDispatchCore &context, uint32_t set, size_t binding, const PackedWeights &packed)
 Allocate a shared buffer on a context and fill it with packed weights.

Variables

constexpr const char * add_shader = "nn_add.comp.spv"
constexpr const char * attention_mix_shader = "nn_attention_mix.comp.spv"
constexpr const char * attention_scores_shader = "nn_attention_scores.comp.spv"
constexpr uint32_t conv1d_activation_shift = 2
 nn_conv1d and nn_conv1d_grouped flag bits 2 and 3: the output activation, 0 none, 1 ReLU, 2 sigmoid, 3 GELU.
constexpr uint32_t conv1d_flag_bias = 1
 nn_conv1d flag bit: add the bias.
constexpr uint32_t conv1d_flag_relu_input = 2
 nn_conv1d flag bit: apply ReLU to the input.
constexpr const char * conv1d_shader = "nn_conv1d.comp.spv"
constexpr uint32_t element_workgroup = 64
 Invocations per workgroup of the element-wise kernels.
constexpr const char * frame_audio_shader = "nn_frame_audio.comp.spv"
constexpr const char * grouped_conv1d_shader = "nn_conv1d_grouped.comp.spv"
constexpr uint32_t lstm_max_hidden = 256
 Widest hidden state nn_lstm_sequence supports.
constexpr const char * lstm_sequence_shader = "nn_lstm_sequence.comp.spv"
constexpr uint32_t lstm_workgroup = 512
 Invocations of the one workgroup nn_lstm_sequence runs in.
constexpr const char * magnitude_shader = "nn_magnitude.comp.spv"
constexpr uint32_t max_groups_per_axis = 32768
 Most workgroups the stages put on one axis; a larger dispatch continues along y.
constexpr uint32_t normalize_activation_shift = 3
 nn_normalize flag bits 3 and 4: the output activation, 0 none, 3 GELU.
constexpr uint32_t normalize_flag_affine = 2
 nn_normalize flag bit: multiply by weight and add bias.
constexpr uint32_t normalize_flag_affine_outer = 4
 nn_normalize flag bit: weight and bias are indexed by the outer index instead of the position along extent.
constexpr uint32_t normalize_flag_apply = 1
 nn_normalize flag bit: write the normalised values instead of measuring the rows.
constexpr const char * normalize_shader = "nn_normalize.comp.spv"
constexpr const char * softmax_shader = "nn_softmax.comp.spv"