ggml: bound views by the bytes their strides reach (#31584)
* ggml: bound views by the bytes their strides reach A view was checked against its source with the size of a contiguous tensor of the same shape, computed before its strides were set. Views whose rows overlap failed that check although they stay inside their source, and views with wider strides passed it while reaching past the end. The view functions now pass their strides to the tensor constructor, which checks the bytes they actually reach, like ggml_nbytes. The conv windows of delta_net are created with all their rows at once instead of being widened after the check. * ggml: assert that a strided view starts from contiguous elements The view functions set nb[0] to the type size, so the source must have contiguous elements along dim 0 for the view to read them.
This commit is contained in:
1 parent
960b1d51b7
commit
bbb02c93e9
2 files changed
+38
-38
No files matched your search
@@ -509,12 +509,11 @@ ggml_tensor * llm_build_delta_net_base::build_conv_state(
|
||||
|
||||
// window w starts at column n - (Kw - 1) + w (ascending time) and is rollback slot Kw - 1 - w
|
||||
// slots reaching back past this ubatch are left unwritten, like the ssm snapshots in build_recurrent_attn
|
||||
// the windows overlap, so the view is created with one window and widened after the size check
|
||||
// consecutive windows start one element apart, so they overlap
|
||||
ggml_tensor * windows = ggml_view_4d(ctx0, conv_input,
|
||||
conv_kernel_size - 1, 1, conv_channels, n_seqs,
|
||||
conv_kernel_size - 1, Kw, conv_channels, n_seqs,
|
||||
ggml_element_size(conv_input), conv_input->nb[1], conv_input->nb[2],
|
||||
ggml_row_size(conv_input->type, n - (Kw - 1)));
|
||||
windows->ne[1] = Kw;
|
||||
|
||||
// [d-1, slot, channel, seq] view of the cells of this ubatch
|
||||
ggml_tensor * slots = ggml_view_4d(ctx0, conv_states_all,
|
||||
|
||||
Reference in new issue
Block a user