MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ normalize_apply_stage()

DependencyStage MayaFlux::Yantra::TensorKernels::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 )
inlinenodiscard

The nn_normalize dispatch that writes (x - mean) * scale from the measures of normalize_stats_stage.

Parameters
srcDevice address of the tensor.
statsDevice address of the row measures.
weightDevice address of the weight, ignored when affine is None.
biasDevice address of the bias, ignored when affine is None.
dstDevice address of the output, which may be src.
affineWhich index selects the weight and bias.
activationApplied last. None and Gelu are supported.
Exceptions
std::invalid_argumentWhen an extent is 0 or the activation is not supported.

Definition at line 175 of file Stages.hpp.

177{
178 if (outer == 0 || extent == 0 || inner == 0) {
179 detail::refuse("Normalize needs an outer, a normalised and an inner extent of at least 1");
180 }
181 if (activation != Activation::None && activation != Activation::Gelu) {
182 detail::refuse("Normalize applies no activation or GELU");
183 }
184 const uint32_t flags = normalize_flag_apply
185 | (affine != NormAffine::None ? normalize_flag_affine : 0U)
187 | (static_cast<uint32_t>(activation) << normalize_activation_shift);
188 const NormalizePC pc { .src = src, .stats = stats, .weight = weight, .bias = bias, .dst = dst,
189 .outer = outer, .extent = extent, .inner = inner, .epsilon = 0.0F, .flags = flags, .reserved = 0 };
190 return detail::make_grid_stage(normalize_shader, pc, static_cast<size_t>(outer) * extent * inner);
191}
void refuse(std::string_view message)
Definition Layers.hpp:74
DependencyStage make_grid_stage(const char *shader, const PC &pc, size_t invocations)
Definition Stages.hpp:38
constexpr uint32_t normalize_flag_affine_outer
nn_normalize flag bit: weight and bias are indexed by the outer index instead of the position along e...
Definition Layouts.hpp:46
constexpr uint32_t normalize_flag_affine
nn_normalize flag bit: multiply by weight and add bias.
Definition Layouts.hpp:44
@ Outer
The outer index, as a per channel normalisation over time does.
Definition Layers.hpp:69
constexpr const char * normalize_shader
Definition Layouts.hpp:28
constexpr uint32_t normalize_flag_apply
nn_normalize flag bit: write the normalised values instead of measuring the rows.
Definition Layouts.hpp:42
constexpr uint32_t normalize_activation_shift
nn_normalize flag bits 3 and 4: the output activation, 0 none, 3 GELU.
Definition Layouts.hpp:48

References Gelu, MayaFlux::Yantra::TensorKernels::detail::make_grid_stage(), None, normalize_activation_shift, normalize_flag_affine, normalize_flag_affine_outer, normalize_flag_apply, normalize_shader, Outer, and MayaFlux::Yantra::TensorKernels::detail::refuse().

Referenced by MayaFlux::Yantra::HubertPhonemeModel::Impl::run().

Here is the call graph for this function:
Here is the caller graph for this function: