MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / scale_last_dim

Function scale_last_dim

src/models/vevo2/components.cpp:546–556  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

544 const auto v = source.require_f32(prefix + ".weight_v", {out_channels, in_channels, kernel_size});
545 std::vector<float> weight(v.size());
546 const int64_t row_size = in_channels * kernel_size;
547 for (int64_t out = 0; out < out_channels; ++out) {
548 double sum = 0.0;
549 const int64_t base = out * row_size;
550 for (int64_t i = 0; i < row_size; ++i) {
551 const float value = v[static_cast<size_t>(base + i)];
552 sum += static_cast<double>(value) * static_cast<double>(value);
553 }
554 const double norm = std::sqrt(sum);
555 if (norm == 0.0) {
556 throw std::runtime_error("Vevo2 weight-norm tensor has zero norm: " + prefix);
557 }
558 const float scale = static_cast<float>(static_cast<double>(g[static_cast<size_t>(out)]) / norm);
559 for (int64_t i = 0; i < row_size; ++i) {

Callers 1

Calls 4

reshape_tensorFunction · 0.85
wrap_tensorFunction · 0.85
ggml_mulFunction · 0.85
repeat_likeFunction · 0.70

Tested by

no test coverage detected