mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-07-03 21:20:49 +08:00
Clarify tensor usage and structural metadata guidelines
This commit is contained in:
parent
8a207df688
commit
25b6a15700
13
AGENTS.md
13
AGENTS.md
@ -177,11 +177,14 @@
|
|||||||
- Do not use tensors as general-purpose Python data structures. Keep metadata,
|
- Do not use tensors as general-purpose Python data structures. Keep metadata,
|
||||||
bookkeeping, counters, flags, shape math, padding math, index planning, memory
|
bookkeeping, counters, flags, shape math, padding math, index planning, memory
|
||||||
estimates, and control-flow decisions in plain Python values unless the data
|
estimates, and control-flow decisions in plain Python values unless the data
|
||||||
must participate directly in tensor computation. Split points, slice
|
must participate directly in tensor computation. Do not create tensors for
|
||||||
boundaries, sequence offsets, and similar structural indices should be Python
|
structural metadata that is only used for Python-side control flow. Sequence
|
||||||
ints/lists after validation, not CPU tensors kept only to drive Python-side
|
lengths, cumulative offsets, split indices, window counts, slice boundaries,
|
||||||
control flow. Avoid creating temporary tensors just to use tensor methods for
|
and repeat counts should be kept as Python ints/lists from the point they are
|
||||||
scalar or structural calculations.
|
computed. Do not build them as CPU/GPU tensors and then cast, move, validate,
|
||||||
|
or convert them back to Python for `split`, `tensor_split`, indexing plans,
|
||||||
|
loops, or cache keys. Avoid creating temporary tensors just to use tensor
|
||||||
|
methods for scalar or structural calculations.
|
||||||
- Avoid unnecessary casts and transfers. Preserve the intended compute dtype,
|
- Avoid unnecessary casts and transfers. Preserve the intended compute dtype,
|
||||||
storage dtype, bias dtype, and original tensor shape metadata.
|
storage dtype, bias dtype, and original tensor shape metadata.
|
||||||
- Keep model-native latent layout handling inside the model or latent-format
|
- Keep model-native latent layout handling inside the model or latent-format
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user