MCPcopy Create free account
hub / github.com/Voine/ChatWaifu_Mobile / embedding

Function embedding

VITS/src/main/cpp/vits/utils.cpp:1000–1017  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

998}
999
1000Mat embedding(const Mat &x, const Mat &weight, const Option &opt) {
1001 if (x.empty() || weight.empty()) return {};
1002 Mat output(weight.w, x.w * x.h);
1003 if (output.empty()) return {};
1004
1005#pragma omp parallel for num_threads(opt.num_threads)
1006 for (int i = 0; i < x.c; i++){
1007 const float *x_p = x.channel(i);
1008 const float *w_p = weight.channel(i);
1009 float *ptr = output.channel(i);
1010 for (int j = 0; j < x.w * x.h; j++) {
1011 int word_index = static_cast<int>(x_p[j]);
1012 memcpy(ptr, w_p + weight.w * word_index, weight.w * sizeof(float));
1013 ptr += output.w;
1014 }
1015 }
1016 return output;
1017}
1018
1019Mat flip(const Mat &x, const Option &opt, int dim) {
1020 Mat output;

Callers 2

emb_g_forwardMethod · 0.85
forwardMethod · 0.85

Calls 2

emptyMethod · 0.45
channelMethod · 0.45

Tested by

no test coverage detected