Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to rng, not recreating a new generator every time. #6

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/include/ggml-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,13 @@ struct ggml_tensor* concat_3d(struct ggml_context* ctx, struct ggml_tensor* a, s
return b_set;
}

extern std::default_random_engine rng;

struct ggml_tensor* tensor_randn(struct ggml_context* ctx, struct ggml_allocr* allocr, std::vector<int64_t> dims) {
auto tensor = ggml_new_tensor(ctx, DEFAULT_TENSOR_TYPE, dims.size(), dims.data());
ALLOC(tensor)
auto data = static_cast<float*>(tensor->data);
auto size = ggml_nelements(tensor) ;
std::mt19937 rng;
std::normal_distribution<float> dist(0.0f, 1.0f);
for (int i = 0; i < size; ++i) {
data[i] = dist(rng);
Expand Down
2 changes: 2 additions & 0 deletions src/vits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ vits_model::~vits_model() {
ggml_free(weights_ctx);
}

std::default_random_engine rng;

template<>
std::vector<int> vits_model::load_vector_impl<int>(const std::string& serialized_data) {
this->log("Loading vector %s\n", serialized_data.c_str());
Expand Down
Loading