MCPcopy Create free account
hub / github.com/pytorch/pytorch / NativeFunction

Class NativeFunction

torchgen/model.py:426–1029  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424# of this at FunctionSchema.
425@dataclass(frozen=True)
426class NativeFunction:
427 # The namespace for this operator. For example, if we have "at::add"
428 # then the namespace would be "at". This enables ops to be registered
429 # through the same DSL with a custom namespace. If not specified, the
430 # default namespace would be "at".
431 namespace: str
432
433 # The function schema of the operator in question. This schema
434 # has been parsed; see FunctionSchema for more about its structure.
435 # (This type is quoted as we are forward referencing a type
436 # defined later in the file. I opted for this ordering of the
437 # classes for expository clarity.)
438 func: "FunctionSchema"
439
440 # Whether or not to generate mutable tensor arguments like regular
441 # ones
442 use_const_ref_for_mutable_tensors: bool
443
444 # Whether or not to omit automatic generation of a DeviceGuard
445 device_guard: bool
446
447 # How to emit automatic generation of device check
448 device_check: DeviceCheckType
449
450 # What python module to put the function in
451 python_module: Optional[str]
452
453 # TODO: figure out what this does
454 category_override: Optional[str]
455
456 # If no variants are specified in native_functions.yaml, this is
457 # assumed to be {'function'}.
458 variants: Set[Variant]
459
460 # Whether or not we should skip generating registrations for
461 # this kernel. This is a bit of a double-edged sword, as manual
462 # registrations don't participate in codegen-based selective build!
463 manual_kernel_registration: bool
464
465 # Whether or not to skip generating TensorMethod/Functions bindings
466 # for this kernel. Technically, this doesn't actually skip generating
467 # the binding; instead, the binding gets generated to __dispatch_{funcname}
468 # so you can make use of the normal binding if you need it.
469 manual_cpp_binding: bool
470
471 # The location in the YAML file were this native function entry was
472 # defined. This is for conveniently reporting error messages!
473 loc: "Location"
474
475 # A list of operators that are expected to be auto-generated for this NativeFunction.
476 # Note: This list isn't actually directly used by the codegen to generate anything.
477 # Instead, the codegen figures out what operators to generate purely based off of
478 # function schema, and uses the autogen declarations to error check.
479 # We expect every NativeFunction that gets auto-generated be explicitly called out
480 # in native_functions.yaml
481 autogen: List["OperatorName"]
482
483 # If non-empty, this kernel is subject to ufunc codegen.

Callers 2

generate_functionFunction · 0.90
from_yamlMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…