pub fn dynamic_element_count_from_bytes(
element: &DataType,
byte_len: usize,
) -> Option<u32>Expand description
Element count a runtime-sized buffer takes from the bytes the caller supplied.
A buffer declared without .with_count(n) has count == 0, which the IR
defines as runtime-sized: its element count is whatever the caller passed for
it on this dispatch. This function is the ONE rule for deriving that count,
byte_len divided by the element width, sub-byte element types included.
The CPU reference, CUDA, and WGPU all size runtime-sized writable buffers through this rule, so a countless declaration reads back the same element count on every backend. A second copy of this arithmetic is how the three paths drifted into returning 4 words, 1 word, and 0 words for one program.
Returns None when the element type has no fixed width or the count does not
fit u32.