MCPcopy Create free account
hub / github.com/pytorch/executorch / create_from_string

Method create_from_string

backends/arm/tosa/specification.py:187–218  ·  view source on GitHub ↗

Create a specification from a standard string format. Example: ``TOSA-1.00.0+INT+FP+int4+cf``. Args: repr (str): Standard representation string. Returns: TosaSpecification: Parsed specification instance. Raises: ValueError: If t

(repr: str)

Source from the content-addressed store, hash-verified

185
186 @staticmethod
187 def create_from_string(repr: str) -> "TosaSpecification":
188 """Create a specification from a standard string format.
189
190 Example: ``TOSA-1.00.0+INT+FP+int4+cf``.
191
192 Args:
193 repr (str): Standard representation string.
194
195 Returns:
196 TosaSpecification: Parsed specification instance.
197
198 Raises:
199 ValueError: If the representation is malformed or version is unsupported.
200
201 """
202 pattern = r"^(TOSA)-([\d.]+)\+(.+)$"
203 match = re.match(pattern, repr)
204 if match:
205 name = match.group(1)
206 version = Version(match.group(2))
207 extras = match.group(3).split("+")
208 if name != "TOSA":
209 raise ValueError(f"Malformed TOSA specification representation: {repr}")
210 match version.major, version.minor:
211 case [1, 0]:
212 return Tosa_1_00(version, extras)
213 case [1, 1]:
214 return Tosa_1_1(version, extras)
215 case _:
216 raise ValueError(f"Wrong TOSA version: {version} from {repr}")
217
218 raise ValueError(f"Failed to parse TOSA specification representation: {repr}")
219
220 def _canonical_key(self) -> "TosaSpecification":
221 """Returns a new TosaSpecification instance with only version and

Calls 5

VersionClass · 0.85
Tosa_1_00Class · 0.85
Tosa_1_1Class · 0.85
splitMethod · 0.80
matchMethod · 0.45