(
a: Argument | TensorOptionsArguments | SelfArgument,
*,
cpp_no_default_args: set[str],
method: bool,
faithful: bool,
has_tensor_options: bool,
)
| 294 | |
| 295 | # Convert an argument into its C++ API form |
| 296 | def argument( |
| 297 | a: Argument | TensorOptionsArguments | SelfArgument, |
| 298 | *, |
| 299 | cpp_no_default_args: set[str], |
| 300 | method: bool, |
| 301 | faithful: bool, |
| 302 | has_tensor_options: bool, |
| 303 | ) -> list[Binding]: |
| 304 | def sub_argument( |
| 305 | a: Argument | TensorOptionsArguments | SelfArgument, |
| 306 | ) -> list[Binding]: |
| 307 | return argument( |
| 308 | a, |
| 309 | cpp_no_default_args=cpp_no_default_args, |
| 310 | method=method, |
| 311 | faithful=faithful, |
| 312 | has_tensor_options=has_tensor_options, |
| 313 | ) |
| 314 | |
| 315 | if isinstance(a, Argument): |
| 316 | binds: ArgName |
| 317 | if a.name == "memory_format" and has_tensor_options: |
| 318 | binds = SpecialArgName.possibly_redundant_memory_format |
| 319 | else: |
| 320 | binds = a.name |
| 321 | default: str | None = None |
| 322 | if a.name not in cpp_no_default_args and a.default is not None: |
| 323 | default = default_expr(a.default, a.type) |
| 324 | return [ |
| 325 | Binding( |
| 326 | nctype=argument_type(a, binds=binds), |
| 327 | name=a.name, |
| 328 | default=default, |
| 329 | argument=a, |
| 330 | ) |
| 331 | ] |
| 332 | elif isinstance(a, TensorOptionsArguments): |
| 333 | raise NotImplementedError("Need to implement type resolution for TensorOptions") |
| 334 | elif isinstance(a, SelfArgument): |
| 335 | if method: |
| 336 | # Caller is responsible for installing implicit this in context! |
| 337 | return [] |
| 338 | else: |
| 339 | return sub_argument(a.argument) |
| 340 | else: |
| 341 | assert_never(a) |
| 342 | |
| 343 | |
| 344 | def arguments( |
no test coverage detected