K i_ ddlZddlmZddlmZddZejdZejddejfdZ ejddejfdZ y) N)TensorDescriptorct|}t|j}t|}|dkr||z }d|cxkr|dz ksJdJd|dksJdt||k(sJdd}d}|||ksJd |||<|j|}d |z |gt |Dcgc]}|j|c}z} ||g|z} ddg|z} t || | | Scc}w) a Given a 2- or 3-dimensional tensor T, this creates a 'ragged descriptor' which behaves like a concatenation (along the first axis) of subarrays of potentially unequal size. The load_ragged and store_ragged device functions can be used to read and write from subarrays T[batch_offset : batch_offset + batch_size] with hardware bounds-checking preventing any sort of leakage outside the subarray. rzlast dimension cannot be raggedz?r:sv ; %AP   2<< " U",, U  Ur#