Skip to content

Commit

Permalink
style: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
leejet committed Aug 24, 2024
1 parent d08d7fa commit c837c5d
Show file tree
Hide file tree
Showing 10 changed files with 935 additions and 945 deletions.
17 changes: 8 additions & 9 deletions conditioner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ struct SDCondition {
struct ggml_tensor* c_concat = NULL;

SDCondition() = default;
SDCondition(struct ggml_tensor* c_crossattn, struct ggml_tensor* c_vector, struct ggml_tensor* c_concat) :
c_crossattn(c_crossattn), c_vector(c_vector), c_concat(c_concat) {}
SDCondition(struct ggml_tensor* c_crossattn, struct ggml_tensor* c_vector, struct ggml_tensor* c_concat)
: c_crossattn(c_crossattn), c_vector(c_vector), c_concat(c_concat) {}
};

struct Conditioner {
Expand Down Expand Up @@ -978,7 +978,6 @@ struct SD3CLIPEmbedder : public Conditioner {
}
};


struct FluxCLIPEmbedder : public Conditioner {
ggml_type wtype;
CLIPTokenizer clip_l_tokenizer;
Expand All @@ -987,8 +986,8 @@ struct FluxCLIPEmbedder : public Conditioner {
std::shared_ptr<T5Runner> t5;

FluxCLIPEmbedder(ggml_backend_t backend,
ggml_type wtype,
int clip_skip = -1)
ggml_type wtype,
int clip_skip = -1)
: wtype(wtype) {
if (clip_skip <= 0) {
clip_skip = 2;
Expand Down Expand Up @@ -1085,10 +1084,10 @@ struct FluxCLIPEmbedder : public Conditioner {
auto& t5_tokens = token_and_weights[1].first;
auto& t5_weights = token_and_weights[1].second;

int64_t t0 = ggml_time_ms();
struct ggml_tensor* hidden_states = NULL; // [N, n_token, 4096]
struct ggml_tensor* chunk_hidden_states = NULL; // [n_token, 4096]
struct ggml_tensor* pooled = NULL; // [768,]
int64_t t0 = ggml_time_ms();
struct ggml_tensor* hidden_states = NULL; // [N, n_token, 4096]
struct ggml_tensor* chunk_hidden_states = NULL; // [n_token, 4096]
struct ggml_tensor* pooled = NULL; // [768,]
std::vector<float> hidden_states_vec;

size_t chunk_len = 256;
Expand Down
3 changes: 1 addition & 2 deletions denoiser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ struct DiscreteFlowDenoiser : public Denoiser {
}
};


float flux_time_shift(float mu, float sigma, float t) {
return std::exp(mu) / (std::exp(mu) + std::pow((1.0 / t - 1.0), sigma));
}
Expand All @@ -369,7 +368,7 @@ struct FluxFlowDenoiser : public Denoiser {
void set_parameters(float shift = 1.15f) {
this->shift = shift;
for (int i = 1; i < TIMESTEPS + 1; i++) {
sigmas[i - 1] = t_to_sigma(i/TIMESTEPS * TIMESTEPS);
sigmas[i - 1] = t_to_sigma(i / TIMESTEPS * TIMESTEPS);
}
}

Expand Down
7 changes: 3 additions & 4 deletions diffusion_model.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef __DIFFUSION_MODEL_H__
#define __DIFFUSION_MODEL_H__

#include "flux.hpp"
#include "mmdit.hpp"
#include "unet.hpp"
#include "flux.hpp"

struct DiffusionModel {
virtual void compute(int n_threads,
Expand Down Expand Up @@ -124,13 +124,12 @@ struct MMDiTModel : public DiffusionModel {
}
};


struct FluxModel : public DiffusionModel {
Flux::FluxRunner flux;

FluxModel(ggml_backend_t backend,
ggml_type wtype,
SDVersion version = VERSION_FLUX_DEV)
ggml_type wtype,
SDVersion version = VERSION_FLUX_DEV)
: flux(backend, wtype, version) {
}

Expand Down
Loading

0 comments on commit c837c5d

Please sign in to comment.