Skip to content

Commit 7aeb2fa

Browse files
committed
perf: sync ggml
1 parent 24636d4 commit 7aeb2fa

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

stable-diffusion.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,11 @@ struct DownSample {
11821182
}
11831183
}
11841184

1185-
static void asymmetric_pad(struct ggml_tensor* dst, const struct ggml_tensor* a, const struct ggml_tensor* b) {
1185+
// TODO: making it parallel
1186+
static void asymmetric_pad(struct ggml_tensor* dst,
1187+
const struct ggml_tensor* a,
1188+
const struct ggml_tensor* b,
1189+
int ith, int nth, void * userdata) {
11861190
assert(sizeof(dst->nb[0]) == sizeof(float));
11871191
assert(sizeof(a->nb[0]) == sizeof(float));
11881192
assert(sizeof(b->nb[0]) == sizeof(float));
@@ -1213,7 +1217,7 @@ struct DownSample {
12131217
auto pad_x = ggml_new_tensor_4d(ctx, x->type, x->ne[0] + 1, x->ne[1] + 1, x->ne[2], x->ne[3]);
12141218
ggml_set_dynamic(ctx, dynamic);
12151219

1216-
x = ggml_map_custom2_inplace_f32(ctx, pad_x, x, asymmetric_pad);
1220+
x = ggml_map_custom2_inplace(ctx, pad_x, x, asymmetric_pad, 1, NULL);
12171221
x = ggml_conv_2d(ctx, op_w, x, 2, 2, 0, 0, 1, 1);
12181222
} else {
12191223
x = ggml_conv_2d(ctx, op_w, x, 2, 2, 1, 1, 1, 1);
@@ -2684,13 +2688,7 @@ class StableDiffusionGGML {
26842688

26852689
const size_t num_bytes = nelements / ggml_blck_size(ggml_type(ttype)) * ggml_type_size(ggml_type(ttype));
26862690

2687-
if (num_bytes != ggml_nbytes(tensor)) {
2688-
LOG_ERROR("tensor '%s' has wrong size in model file: got %zu, expected %zu",
2689-
name.data(), num_bytes, ggml_nbytes(tensor));
2690-
return false;
2691-
}
2692-
2693-
file.read(reinterpret_cast<char*>(tensor->data), ggml_nbytes(tensor));
2691+
file.read(reinterpret_cast<char*>(tensor->data), num_bytes);
26942692

26952693
total_size += ggml_nbytes(tensor);
26962694
}

0 commit comments

Comments
 (0)