2
2
from typing import Dict , List , Sequence , Union
3
3
4
4
from torchgen .api import cpp
5
-
6
5
from torchgen .api .types import DispatcherSignature
7
6
from torchgen .code_template import CodeTemplate
8
7
from torchgen .context import with_native_function
@@ -376,22 +375,11 @@ def format_postrecord_trace(f: NativeFunction) -> str:
376
375
return POST_RECORD_TRACE .substitute (add_trace_outputs = outputs )
377
376
378
377
379
- def declare_returned_variables (f : NativeFunction ) -> str :
380
- modifies_arguments = f .func .kind () in (SchemaKind .inplace , SchemaKind .out )
381
- if modifies_arguments :
382
- return ""
383
- if len (f .func .returns ) == 1 :
384
- return ""
385
- types = [cpp .return_type (r , symint = True ) for r in f .func .returns ]
386
- names = cpp .return_names (f )
387
- return "\n " .join (f"{ type .cpp_type ()} { name } ;" for type , name in zip (types , names ))
388
-
389
-
390
378
def tie_return_values (f : NativeFunction ) -> str :
391
379
if len (f .func .returns ) == 1 :
392
380
return f'auto { f .func .returns [0 ].name or "result" } '
393
381
names = cpp .return_names (f )
394
- return f'std::tie( { ", " .join (names )} ) '
382
+ return f'auto [ { ", " .join (names )} ] '
395
383
396
384
397
385
def get_return_value (f : NativeFunction ) -> str :
@@ -415,7 +403,6 @@ def emit_trace_body(f: NativeFunction) -> List[str]:
415
403
trace_body : List [str ] = []
416
404
417
405
trace_body .append (format_prerecord_trace (f ))
418
- trace_body .append (declare_returned_variables (f ))
419
406
420
407
dispatcher_sig = DispatcherSignature .from_schema (f .func )
421
408
dispatcher_exprs = dispatcher_sig .exprs ()
@@ -433,7 +420,8 @@ def emit_trace_body(f: NativeFunction) -> List[str]:
433
420
)
434
421
435
422
# Note that this calls the slow, dispatching variants of manual_cpp_binding ops.
436
- # We could probably work harder to ensure that the fast variants are called instead, but the perf benefit would be minimal.
423
+ # We could probably work harder to ensure that the fast variants are
424
+ # called instead, but the perf benefit would be minimal.
437
425
trace_body .append (
438
426
TRACE_DISPATCH .substitute (
439
427
assign_return_values = assign_return_values ,
0 commit comments