mirror of
				https://github.com/ggml-org/llama.cpp.git
				synced 2025-11-03 09:22:01 +00:00 
			
		
		
		
	ggml : ggml_rope now takes a vector with positions instead of n_past
This commit is contained in:
		@@ -1404,6 +1404,11 @@ int main(int argc, const char ** argv) {
 | 
			
		||||
                    for (int n_past = 1; n_past < ne2[2]; ++n_past) {
 | 
			
		||||
                        x[0] = get_random_tensor_f32(ctx0, ndims, ne2, -1.0f, 1.0f);
 | 
			
		||||
 | 
			
		||||
                        struct ggml_tensor * p = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne2[2]);
 | 
			
		||||
                        for (int i = 0; i < ne2[2]; ++i) {
 | 
			
		||||
                            ((int32_t *) p->data)[i] = n_past + i;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        ggml_set_param(ctx0, x[0]);
 | 
			
		||||
 | 
			
		||||
                        const bool skip_past = (mode & 1);
 | 
			
		||||
@@ -1415,7 +1420,7 @@ int main(int argc, const char ** argv) {
 | 
			
		||||
                            continue;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        struct ggml_tensor * f = ggml_sum(ctx0, ggml_rope(ctx0, x[0], n_past, n_rot, mode, 0));
 | 
			
		||||
                        struct ggml_tensor * f = ggml_sum(ctx0, ggml_rope(ctx0, x[0], p, n_rot, mode, 0));
 | 
			
		||||
 | 
			
		||||
                        GGML_PRINT_DEBUG("rope f32: n_past: %d n_rot: %d mode: %d\n", n_past, n_rot, mode);
 | 
			
		||||
                        check_gradient("rope f32", ctx0, x, f, ndims, nargs, 1e-2f, 1e-3f, INFINITY);
 | 
			
		||||
@@ -1438,6 +1443,11 @@ int main(int argc, const char ** argv) {
 | 
			
		||||
                    for (int n_past = 1; n_past < ne2[2]; ++n_past) {
 | 
			
		||||
                        x[0] = get_random_tensor_f16(ctx0, ndims, ne2, -1.0f, 1.0f);
 | 
			
		||||
 | 
			
		||||
                        struct ggml_tensor * p = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne2[2]);
 | 
			
		||||
                        for (int i = 0; i < ne2[2]; ++i) {
 | 
			
		||||
                            ((int32_t *) p->data)[i] = n_past + i;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        ggml_set_param(ctx0, x[0]);
 | 
			
		||||
 | 
			
		||||
                        const bool skip_past = (mode & 1);
 | 
			
		||||
@@ -1449,7 +1459,7 @@ int main(int argc, const char ** argv) {
 | 
			
		||||
                            continue;
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        struct ggml_tensor * f = ggml_sum(ctx0, ggml_rope(ctx0, x[0], n_past, n_rot, mode, 0));
 | 
			
		||||
                        struct ggml_tensor * f = ggml_sum(ctx0, ggml_rope(ctx0, x[0], p, n_rot, mode, 0));
 | 
			
		||||
 | 
			
		||||
                        GGML_PRINT_DEBUG("rope f16: n_past: %d n_rot: %d mode: %d\n", n_past, n_rot, mode);
 | 
			
		||||
                        check_gradient("rope f16", ctx0, x, f, ndims, nargs, 1e-1f, 1e-1f, INFINITY);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user