We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 203d053 commit 37c5e3eCopy full SHA for 37c5e3e
flux.hpp
@@ -891,6 +891,11 @@ namespace Flux {
891
int64_t C = x->ne[2];
892
int64_t H = x->ne[1];
893
int64_t W = x->ne[0];
894
+ if (params.patch_size == 1) {
895
+ x = ggml_reshape_3d(ctx, x, H * W, C, N); // [N, C, H*W]
896
+ x = ggml_cont(ctx, ggml_permute(ctx, x, 1, 0, 2, 3)); // [N, H*W, C]
897
+ return x;
898
+ }
899
int64_t p = params.patch_size;
900
int64_t h = H / params.patch_size;
901
int64_t w = W / params.patch_size;
@@ -925,6 +930,12 @@ namespace Flux {
925
930
int64_t W = w * params.patch_size;
926
931
927
932
933
934
+ x = ggml_cont(ctx, ggml_permute(ctx, x, 1, 0, 2, 3)); // [N, C, H*W]
935
+ x = ggml_reshape_4d(ctx, x, W, H, C, N); // [N, C, H, W]
936
937
938
+
928
939
GGML_ASSERT(C * p * p == x->ne[0]);
929
940
941
x = ggml_reshape_4d(ctx, x, p * p, C, w * h, N); // [N, h*w, C, p*p]
0 commit comments