Skip to content

Commit c40a17a

Browse files
committed
ggml : remove adding extra dim timestep embedding
This commit updates the ggml_timestep_embedding function to no longer add an extra dimension when the specified dimension is odd. The motivation for this change is that this introduces an unnecessary dimension when the dimension is odd, which caused an issue in the kernels which were not expecting this extra dimension and it resulted in uninitialized memory for the second to last dimension.
1 parent 51abc96 commit c40a17a

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

ggml/src/ggml.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,12 +4923,8 @@ struct ggml_tensor * ggml_timestep_embedding(
49234923
struct ggml_tensor * timesteps,
49244924
int dim,
49254925
int max_period) {
4926-
int actual_dim = dim;
4927-
if (dim % 2 != 0) {
4928-
actual_dim = dim + 1;
4929-
}
49304926

4931-
struct ggml_tensor * result = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, actual_dim, timesteps->ne[0]);
4927+
struct ggml_tensor * result = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, dim, timesteps->ne[0]);
49324928

49334929
ggml_set_op_params_i32(result, 0, dim);
49344930
ggml_set_op_params_i32(result, 1, max_period);

0 commit comments

Comments
 (0)