-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
Tip
Never use [] for shape_signature. Always use None for static shapes.
If you get typing errors from this, just add a # type: ignore comment to suppress mypy warnings.1
Since there is no formal documentation for the circle dynamic shape specification, confusion and errors may occur during development and operation. Below is a summary of the spec, including potential error cases and important notes.
Basic
Dynamic Shape in Torch Exported Program
- torch tensor.shape:
[s, 3, 3, 4]
(wheresrepresents a dynamic dimension. type: torch.SymInt)
Dynamic Shape Definition in Circle
| Field | Example |
|---|---|
circle::tensor.shape |
[1,3,3,4] |
circle::tensor.shape_signature |
[-1, 3, 3, 4] (if dynamic shape) |
circle::tensor.shape_signature |
None (if no dynamic shape) |
tensor.shape_signature = None
→ Valid (OK)tensor.shape_signature = []
→ Invalid, causes errors in the ONE runtime!
Note: For static shapes,
shape_signaturemust be set toNone.
Using an empty list ([]) is not allowed because ONE runtime may mistakenly treat it as a shape, resulting in errors.
Related: ONE Runtime Behavior
- If the
shape_signaturefield exists in the circle,
→ The runtime usesshape_signature. - If
shape_signaturedoes not exist,
→ The runtime falls back to usingshape.
Caution When Generating Circle Files (e.g., using TICO)
- Assigning an empty list (
[]) toshape_signaturecauses the field to be created in the circle file. - This leads to malfunctions in the ONE runtime.
- Therefore, for static shapes, the
shape_signaturefield should not be created at all.
Invalid Typing in Circle Schema
- The
circle_schemapython package we are using has an significant typing error.- To set
tensor.shapeSignature = None, we should force mypy assert ignore manually. Related Issue: https://github.sec.samsung.net/AIP/python-tools/issues/887
- To set
Footnotes
-
Error of Flatbuffers. It forced Optional[List[int]] -> List[int] while generating python circle_schema package. ↩
periannath
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation