Skip to content
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
2 changes: 1 addition & 1 deletion examples/common/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ ArgOptions SDGenerationParams::get_options() {
&hires_upscaler},
{"",
"--extra-sample-args",
"extra sampler/scheduler/guidance args, key=value list. CFG supports guidance_schedule; APG supports apg_eta, apg_momentum, apg_norm_threshold, apg_norm_threshold_smoothing; SLG supports slg_uncond; lcm supports noise_clip_std, noise_scale_start, noise_scale_end; flux supports base_shift, max_shift; ltx2 supports max_shift, base_shift, stretch, terminal; euler_ge supports gamma; beta scheduler supports alpha, beta; logit_normal supports mu, std, logsnr_min, logsnr_max, resolution_aware; lms supports lms_max_order, lms_shift, lms_divisions",
"extra sampler/scheduler/guidance args, key=value list. CFG supports guidance_schedule; APG supports apg_eta, apg_momentum, apg_norm_threshold, apg_norm_threshold_smoothing; SLG supports slg_uncond; lcm supports noise_clip_std, noise_scale_start, noise_scale_end; flux supports base_shift, max_shift; ltx2 supports max_shift, base_shift, stretch, terminal; euler_ge supports gamma; beta scheduler supports alpha, beta; logit_normal supports mu, std, logsnr_min, logsnr_max, resolution_aware; lms supports lms_max_order, lms_shift, lms_divisions; noise-injecting samplers support noise_sampler with value iid (default except for dpm++2m_sde_bt) or brownian_tree; brownian_tree_rng supports cpu (default), cuda, std_default or sampler_rng",
(int)',',
&extra_sample_args},
{"",
Expand Down
7 changes: 7 additions & 0 deletions src/core/rng.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
#ifndef __SD_CORE_RNG_HPP__
#define __SD_CORE_RNG_HPP__

#include <cstdint>
#include <memory>
#include <random>
#include <vector>

class RNG {
public:
virtual void manual_seed(uint64_t seed) = 0;
virtual std::vector<float> randn(uint32_t n) = 0;
virtual std::shared_ptr<RNG> clone() const = 0;
};

class STDDefaultRNG : public RNG {
private:
std::default_random_engine generator;

public:
std::shared_ptr<RNG> clone() const override {
return std::make_shared<STDDefaultRNG>(*this);
}

void manual_seed(uint64_t seed) override {
generator.seed((unsigned int)seed);
}
Expand Down
6 changes: 6 additions & 0 deletions src/core/rng_mt19937.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#ifndef __SD_CORE_RNG_MT19937_HPP__
#define __SD_CORE_RNG_MT19937_HPP__

#include <array>
#include <cmath>
#include <limits>
#include <vector>

#include "core/rng.hpp"
Expand Down Expand Up @@ -123,6 +125,10 @@ class MT19937RNG : public RNG {
public:
MT19937RNG(uint64_t seed = 0) { manual_seed(seed); }

std::shared_ptr<RNG> clone() const override {
return std::make_shared<MT19937RNG>(*this);
}

void manual_seed(uint64_t seed) override {
s.seed_ = seed;
s.seeded_ = true;
Expand Down
4 changes: 4 additions & 0 deletions src/core/rng_philox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ class PhiloxRNG : public RNG {
this->offset = 0;
}

std::shared_ptr<RNG> clone() const override {
return std::make_shared<PhiloxRNG>(*this);
}

void manual_seed(uint64_t seed) override {
this->seed = seed;
this->offset = 0;
Expand Down
Loading
Loading