Skip to content

Commit 0165da2

Browse files
authored
[TorchToTosa] Support scalar (rank-0) multi dim reductions (#4596)
Pytorch allows reducing a rank-0 tensor with dim=0 or dim=-1, which yields the scalar itself. TOSA has no rank-0 axis to reduce over, so lower these cases as a no-op reduction over an empty set of axes.
1 parent d3e7bdd commit 0165da2

5 files changed

Lines changed: 296 additions & 0 deletions

File tree

lib/Conversion/TorchToTosa/TorchToTosa.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,20 @@ class ConvertAtenMultipleDimsReductionOp
15771577
reduceDims.push_back(i);
15781578
}
15791579

1580+
// PyTorch accepts dim=0 and dim=-1 for scalar reductions. TOSA
1581+
// reduction ops currently require at least rank-1 tensors, and scalar
1582+
// reductions are semantically no-ops, so lower them as no-axis reductions.
1583+
if (inputRank == 0) {
1584+
if (reduceDims.size() > 1)
1585+
return rewriter.notifyMatchFailure(
1586+
op, "scalar reduce dim appears multiple times");
1587+
if (!reduceDims.empty() && reduceDims.front() != 0 &&
1588+
reduceDims.front() != -1)
1589+
return rewriter.notifyMatchFailure(
1590+
op, "scalar reduce dim is statically invalid");
1591+
reduceDims.clear();
1592+
}
1593+
15801594
int64_t N = reduceDims.size();
15811595
for (unsigned i = 0; i < N; i++) {
15821596
reduceDims[i] = toPositiveDim(reduceDims[i], inputRank);

projects/pt1/e2e_testing/xfail_sets.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@
575575
"ElementwiseRemainderTensorModule_Int_Float_NegativeDivisor_basic",
576576
"ElementwiseRemainderTensorModule_Int_NegativeDividend_basic",
577577
"ElementwiseRemainderTensorModule_Int_NegativeDivisor_basic",
578+
"LinalgVectorNormRank0Module_basic",
578579
"MaxPool1dCeilModeTrueModule_basic",
579580
"MaxPool1dStaticCeilModeTrueModule_basic",
580581
"MaxUnpool3dModulePad0_basic",
@@ -2423,6 +2424,7 @@
24232424
"LiftFreshCopyModule_basic",
24242425
"LinalgVectorNormKeepDimModule_basic",
24252426
"LinalgVectorNormModule_basic",
2427+
"LinalgVectorNormRank0Module_basic",
24262428
"LinalgNormKeepDimModule_basic",
24272429
"MaskedFillScalarDefaultModule_basic",
24282430
"MaskedFillScalarIntValueModule_basic",
@@ -2437,6 +2439,8 @@
24372439
"MaxPool2dStaticCeilModeTrueReduceOutputModule_basic",
24382440
"MaxPool2dStaticModule_basic",
24392441
"MeanModule_basic",
2442+
"MeanDimRank0Module_basic",
2443+
"MeanDimRank0DtypeModule_basic",
24402444
"MmDagModule_basic",
24412445
"MoveDimIntModule_basic",
24422446
"MoveDimIntModule_basic",
@@ -2495,6 +2499,9 @@
24952499
"ReduceSumDimIntListKeepDimFloatModule_basic",
24962500
"ReduceSumDimIntListKeepDimIntModule_basic",
24972501
"ReduceSumDimIntListKeepDimNegativeDimStaticModule_basic",
2502+
"ReduceSumDimIntListRank0FloatModule_basic",
2503+
"ReduceSumDimIntListRank0DtypeFloatModule_basic",
2504+
"ReduceSumDimIntListRank0NegativeDimFloatModule_basic",
24982505
"ReduceSumFloatModule_basic",
24992506
"ReduceSumSignedIntModule_basic",
25002507
"ReduceSumUnsignedIntModule_basic",
@@ -3129,6 +3136,7 @@
31293136
"LiftFreshCopyModule_basic",
31303137
"LinalgNormKeepDimComplexModule_basic",
31313138
"LinalgVectorNormComplexModule_basic",
3139+
"LinalgVectorNormRank0Module_basic",
31323140
"LogSoftmaxBackwardModule_basic",
31333141
"LogCumsumExpModule_basic",
31343142
"LogCumsumExpStaticNegativeDimModule_basic",
@@ -3168,6 +3176,7 @@
31683176
"MaxUnpool2dModule_basic",
31693177
"MaxUnpool2dModule_3dInput_basic",
31703178
"MeanDimEmptyDimModule_basic",
3179+
"MeanDimRank0DtypeModule_basic",
31713180
"Mlp1LayerModule_basic",
31723181
"Mlp2LayerModuleNoBias_basic",
31733182
"Mlp2LayerModule_basic",
@@ -3267,6 +3276,7 @@
32673276
"RandIntDtypeModule_basic",
32683277
"RandIntModule_basic",
32693278
"RandIntPinMemoryModule_basic",
3279+
"ReduceSumDimIntListRank0DtypeFloatModule_basic",
32703280
"ReduceFrobeniusNormComplexModule_basic",
32713281
"ReduceL1NormComplexModule_basic",
32723282
"ReduceL2NormComplexModule_basic",

projects/pt1/python/torch_mlir_e2e_test/test_suite/reduction.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,77 @@ def ReduceSumDimIntListFloatModule_basic(module, tu: TestUtils):
463463
# ==============================================================================
464464

465465

466+
class ReduceSumDimIntListRank0FloatModule(torch.nn.Module):
467+
def __init__(self):
468+
super().__init__()
469+
470+
@export
471+
@annotate_args(
472+
[
473+
None,
474+
([], torch.float32, True),
475+
]
476+
)
477+
def forward(self, a):
478+
return torch.sum(a, dim=0)
479+
480+
481+
@register_test_case(module_factory=lambda: ReduceSumDimIntListRank0FloatModule())
482+
def ReduceSumDimIntListRank0FloatModule_basic(module, tu: TestUtils):
483+
module.forward(torch.tensor(3.0, dtype=torch.float32))
484+
485+
486+
# ==============================================================================
487+
488+
489+
class ReduceSumDimIntListRank0DtypeFloatModule(torch.nn.Module):
490+
def __init__(self):
491+
super().__init__()
492+
493+
@export
494+
@annotate_args(
495+
[
496+
None,
497+
([], torch.float32, True),
498+
]
499+
)
500+
def forward(self, a):
501+
return torch.sum(a, dim=0, dtype=torch.float64)
502+
503+
504+
@register_test_case(module_factory=lambda: ReduceSumDimIntListRank0DtypeFloatModule())
505+
def ReduceSumDimIntListRank0DtypeFloatModule_basic(module, tu: TestUtils):
506+
module.forward(torch.tensor(3.0, dtype=torch.float32))
507+
508+
509+
# ==============================================================================
510+
511+
512+
class ReduceSumDimIntListRank0NegativeDimFloatModule(torch.nn.Module):
513+
def __init__(self):
514+
super().__init__()
515+
516+
@export
517+
@annotate_args(
518+
[
519+
None,
520+
([], torch.float32, True),
521+
]
522+
)
523+
def forward(self, a):
524+
return torch.sum(a, dim=-1)
525+
526+
527+
@register_test_case(
528+
module_factory=lambda: ReduceSumDimIntListRank0NegativeDimFloatModule()
529+
)
530+
def ReduceSumDimIntListRank0NegativeDimFloatModule_basic(module, tu: TestUtils):
531+
module.forward(torch.tensor(3.0, dtype=torch.float32))
532+
533+
534+
# ==============================================================================
535+
536+
466537
class ReduceSumDimIntListDtypeFloatModule(torch.nn.Module):
467538
def __init__(self):
468539
super().__init__()
@@ -2206,6 +2277,29 @@ def LinalgVectorNormModule_basic(module, tu: TestUtils):
22062277
# ==============================================================================
22072278

22082279

2280+
class LinalgVectorNormRank0Module(torch.nn.Module):
2281+
def __init__(self) -> None:
2282+
super().__init__()
2283+
2284+
@export
2285+
@annotate_args(
2286+
[
2287+
None,
2288+
([], torch.float32, True),
2289+
]
2290+
)
2291+
def forward(self, a):
2292+
return torch.ops.aten.linalg_vector_norm(a, ord=3.0, dim=[-1], keepdim=False)
2293+
2294+
2295+
@register_test_case(module_factory=lambda: LinalgVectorNormRank0Module())
2296+
def LinalgVectorNormRank0Module_basic(module, tu: TestUtils):
2297+
module.forward(tu.rand())
2298+
2299+
2300+
# ==============================================================================
2301+
2302+
22092303
class LinalgVectorNormKeepDimModule(torch.nn.Module):
22102304
def __init__(self) -> None:
22112305
super().__init__()

projects/pt1/python/torch_mlir_e2e_test/test_suite/stats.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,52 @@ def MeanModule_basic(module, tu: TestUtils):
3535
# ==============================================================================
3636

3737

38+
class MeanDimRank0Module(torch.nn.Module):
39+
def __init__(self):
40+
super().__init__()
41+
42+
@export
43+
@annotate_args(
44+
[
45+
None,
46+
([], torch.float32, True),
47+
]
48+
)
49+
def forward(self, x):
50+
return torch.ops.aten.mean(x, dim=0)
51+
52+
53+
@register_test_case(module_factory=lambda: MeanDimRank0Module())
54+
def MeanDimRank0Module_basic(module, tu: TestUtils):
55+
module.forward(tu.rand())
56+
57+
58+
# ==============================================================================
59+
60+
61+
class MeanDimRank0DtypeModule(torch.nn.Module):
62+
def __init__(self):
63+
super().__init__()
64+
65+
@export
66+
@annotate_args(
67+
[
68+
None,
69+
([], torch.float32, True),
70+
]
71+
)
72+
def forward(self, x):
73+
return torch.ops.aten.mean(x, dim=0, dtype=torch.float64)
74+
75+
76+
@register_test_case(module_factory=lambda: MeanDimRank0DtypeModule())
77+
def MeanDimRank0DtypeModule_basic(module, tu: TestUtils):
78+
module.forward(tu.rand())
79+
80+
81+
# ==============================================================================
82+
83+
3884
class MeanDynamicSizesModule(torch.nn.Module):
3985
def __init__(self):
4086
super().__init__()

test/Conversion/TorchToTosa/basic.mlir

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,50 @@ func.func @test_reduce_mean_dim$basic(%arg0: !torch.vtensor<[3,4,5,6],f32>) -> !
301301

302302
// -----
303303

304+
// CHECK-LABEL: func.func @test_reduce_mean_scalar_dim(
305+
// CHECK-SAME: %[[INPUT:.*]]: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
306+
// CHECK: %[[INPUT_TENSOR:.*]] = torch_c.to_builtin_tensor %[[INPUT]] : !torch.vtensor<[],f32> -> tensor<f32>
307+
// CHECK-NOT: tosa.reduce_sum
308+
// CHECK: %[[IDENTITY:.*]] = tosa.identity %[[INPUT_TENSOR]] : (tensor<f32>) -> tensor<f32>
309+
// CHECK: %[[ONE:.*]] = "tosa.const"() <{values = dense<1.000000e+00> : tensor<f32>}> : () -> tensor<f32>
310+
// CHECK: %[[SCALE:.*]] = "tosa.const"() <{values = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>
311+
// CHECK: %[[MUL:.*]] = tosa.mul %[[IDENTITY]], %[[ONE]], %[[SCALE]] : (tensor<f32>, tensor<f32>, tensor<1xi8>) -> tensor<f32>
312+
// CHECK: %[[RESULT:.*]] = torch_c.from_builtin_tensor %[[MUL]] : tensor<f32> -> !torch.vtensor<[],f32>
313+
// CHECK: return %[[RESULT]] : !torch.vtensor<[],f32>
314+
// CHECK: }
315+
func.func @test_reduce_mean_scalar_dim(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
316+
%dim0 = torch.constant.int 0
317+
%reducedims = torch.prim.ListConstruct %dim0 : (!torch.int) -> !torch.list<int>
318+
%keepdims = torch.constant.bool false
319+
%dtype = torch.constant.none
320+
%0 = torch.aten.mean.dim %arg0, %reducedims, %keepdims, %dtype : !torch.vtensor<[],f32>, !torch.list<int>, !torch.bool, !torch.none -> !torch.vtensor<[],f32>
321+
return %0 : !torch.vtensor<[],f32>
322+
}
323+
324+
// -----
325+
326+
// CHECK-LABEL: func.func @test_reduce_mean_scalar_negative_dim(
327+
// CHECK-SAME: %[[INPUT:.*]]: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
328+
// CHECK: %[[INPUT_TENSOR:.*]] = torch_c.to_builtin_tensor %[[INPUT]] : !torch.vtensor<[],f32> -> tensor<f32>
329+
// CHECK-NOT: tosa.reduce_sum
330+
// CHECK: %[[IDENTITY:.*]] = tosa.identity %[[INPUT_TENSOR]] : (tensor<f32>) -> tensor<f32>
331+
// CHECK: %[[ONE:.*]] = "tosa.const"() <{values = dense<1.000000e+00> : tensor<f32>}> : () -> tensor<f32>
332+
// CHECK: %[[SCALE:.*]] = "tosa.const"() <{values = dense<0> : tensor<1xi8>}> : () -> tensor<1xi8>
333+
// CHECK: %[[MUL:.*]] = tosa.mul %[[IDENTITY]], %[[ONE]], %[[SCALE]] : (tensor<f32>, tensor<f32>, tensor<1xi8>) -> tensor<f32>
334+
// CHECK: %[[RESULT:.*]] = torch_c.from_builtin_tensor %[[MUL]] : tensor<f32> -> !torch.vtensor<[],f32>
335+
// CHECK: return %[[RESULT]] : !torch.vtensor<[],f32>
336+
// CHECK: }
337+
func.func @test_reduce_mean_scalar_negative_dim(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
338+
%dim = torch.constant.int -1
339+
%reducedims = torch.prim.ListConstruct %dim : (!torch.int) -> !torch.list<int>
340+
%keepdims = torch.constant.bool false
341+
%dtype = torch.constant.none
342+
%0 = torch.aten.mean.dim %arg0, %reducedims, %keepdims, %dtype : !torch.vtensor<[],f32>, !torch.list<int>, !torch.bool, !torch.none -> !torch.vtensor<[],f32>
343+
return %0 : !torch.vtensor<[],f32>
344+
}
345+
346+
// -----
347+
304348
// CHECK-LABEL: func.func @test_reduce_sum_dims$basic(
305349
// CHECK-SAME: %[[VAL_0:.*]]: !torch.vtensor<[3,4,5,6],f32>) -> !torch.vtensor<[4,5,6],f32> {
306350
// CHECK: %[[VAL_1:.*]] = torch_c.to_builtin_tensor %[[VAL_0]] : !torch.vtensor<[3,4,5,6],f32> -> tensor<3x4x5x6xf32>
@@ -325,6 +369,44 @@ func.func @test_reduce_sum_dims$basic(%arg0: !torch.vtensor<[3,4,5,6],f32>) -> !
325369

326370
// -----
327371

372+
// CHECK-LABEL: func.func @test_reduce_sum_scalar_dim$basic(
373+
// CHECK-SAME: %[[INPUT:.*]]: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
374+
// CHECK: %[[INPUT_TENSOR:.*]] = torch_c.to_builtin_tensor %[[INPUT]] : !torch.vtensor<[],f32> -> tensor<f32>
375+
// CHECK-NOT: tosa.reduce_sum
376+
// CHECK: %[[IDENTITY:.*]] = tosa.identity %[[INPUT_TENSOR]] : (tensor<f32>) -> tensor<f32>
377+
// CHECK: %[[RESULT:.*]] = torch_c.from_builtin_tensor %[[IDENTITY]] : tensor<f32> -> !torch.vtensor<[],f32>
378+
// CHECK: return %[[RESULT]] : !torch.vtensor<[],f32>
379+
// CHECK: }
380+
func.func @test_reduce_sum_scalar_dim$basic(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
381+
%none = torch.constant.none
382+
%false = torch.constant.bool false
383+
%int0 = torch.constant.int 0
384+
%dims = torch.prim.ListConstruct %int0 : (!torch.int) -> !torch.list<int>
385+
%0 = torch.aten.sum.dim_IntList %arg0, %dims, %false, %none : !torch.vtensor<[],f32>, !torch.list<int>, !torch.bool, !torch.none -> !torch.vtensor<[],f32>
386+
return %0 : !torch.vtensor<[],f32>
387+
}
388+
389+
// -----
390+
391+
// CHECK-LABEL: func.func @test_reduce_sum_scalar_negative_dim$basic(
392+
// CHECK-SAME: %[[INPUT:.*]]: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
393+
// CHECK: %[[INPUT_TENSOR:.*]] = torch_c.to_builtin_tensor %[[INPUT]] : !torch.vtensor<[],f32> -> tensor<f32>
394+
// CHECK-NOT: tosa.reduce_sum
395+
// CHECK: %[[IDENTITY:.*]] = tosa.identity %[[INPUT_TENSOR]] : (tensor<f32>) -> tensor<f32>
396+
// CHECK: %[[RESULT:.*]] = torch_c.from_builtin_tensor %[[IDENTITY]] : tensor<f32> -> !torch.vtensor<[],f32>
397+
// CHECK: return %[[RESULT]] : !torch.vtensor<[],f32>
398+
// CHECK: }
399+
func.func @test_reduce_sum_scalar_negative_dim$basic(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
400+
%none = torch.constant.none
401+
%false = torch.constant.bool false
402+
%int-1 = torch.constant.int -1
403+
%dims = torch.prim.ListConstruct %int-1 : (!torch.int) -> !torch.list<int>
404+
%0 = torch.aten.sum.dim_IntList %arg0, %dims, %false, %none : !torch.vtensor<[],f32>, !torch.list<int>, !torch.bool, !torch.none -> !torch.vtensor<[],f32>
405+
return %0 : !torch.vtensor<[],f32>
406+
}
407+
408+
// -----
409+
328410
// CHECK-LABEL: func.func @test_reduce_sum_empty_dims$basic(
329411
// CHECK-SAME: %[[INPUT_F32:.*]]: !torch.vtensor<[2,3,4],f32>) -> !torch.vtensor<[],f32> {
330412
// CHECK: %[[INPUT_F32_TENSOR:.*]] = torch_c.to_builtin_tensor %[[INPUT_F32]] : !torch.vtensor<[2,3,4],f32> -> tensor<2x3x4xf32>
@@ -405,6 +487,56 @@ func.func @test_linalg_vector_norm$basic(%arg0: !torch.vtensor<[3,151,64],f32>)
405487

406488
// -----
407489

490+
// CHECK-LABEL: func.func @test_linalg_vector_norm_scalar_dim(
491+
// CHECK-SAME: %[[INPUT:.*]]: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
492+
// CHECK: %[[INPUT_TENSOR:.*]] = torch_c.to_builtin_tensor %[[INPUT]] : !torch.vtensor<[],f32> -> tensor<f32>
493+
// CHECK: %[[ORD:.*]] = "tosa.const"() <{values = dense<3.000000e+00> : tensor<f32>}> : () -> tensor<f32>
494+
// CHECK: %[[ABS:.*]] = tosa.abs %[[INPUT_TENSOR]] : (tensor<f32>) -> tensor<f32>
495+
// CHECK: %[[POW:.*]] = tosa.pow %[[ABS]], %[[ORD]] : (tensor<f32>, tensor<f32>) -> tensor<f32>
496+
// CHECK-NOT: tosa.reduce_sum
497+
// CHECK: %[[IDENTITY:.*]] = tosa.identity %[[POW]] : (tensor<f32>) -> tensor<f32>
498+
// CHECK: %[[RECIPROCAL:.*]] = tosa.reciprocal %[[ORD]] : (tensor<f32>) -> tensor<f32>
499+
// CHECK: %[[RESULT_TENSOR:.*]] = tosa.pow %[[IDENTITY]], %[[RECIPROCAL]] : (tensor<f32>, tensor<f32>) -> tensor<f32>
500+
// CHECK: %[[RESULT:.*]] = torch_c.from_builtin_tensor %[[RESULT_TENSOR]] : tensor<f32> -> !torch.vtensor<[],f32>
501+
// CHECK: return %[[RESULT]] : !torch.vtensor<[],f32>
502+
// CHECK: }
503+
func.func @test_linalg_vector_norm_scalar_dim(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
504+
%ord = torch.constant.float 3.000000e+00
505+
%dim = torch.constant.int 0
506+
%keepdims = torch.constant.bool false
507+
%dtype = torch.constant.none
508+
%dims = torch.prim.ListConstruct %dim : (!torch.int) -> !torch.list<int>
509+
%0 = torch.aten.linalg_vector_norm %arg0, %ord, %dims, %keepdims, %dtype : !torch.vtensor<[],f32>, !torch.float, !torch.list<int>, !torch.bool, !torch.none -> !torch.vtensor<[],f32>
510+
return %0 : !torch.vtensor<[],f32>
511+
}
512+
513+
// -----
514+
515+
// CHECK-LABEL: func.func @test_linalg_vector_norm_scalar_negative_dim(
516+
// CHECK-SAME: %[[INPUT:.*]]: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
517+
// CHECK: %[[INPUT_TENSOR:.*]] = torch_c.to_builtin_tensor %[[INPUT]] : !torch.vtensor<[],f32> -> tensor<f32>
518+
// CHECK: %[[ORD:.*]] = "tosa.const"() <{values = dense<3.000000e+00> : tensor<f32>}> : () -> tensor<f32>
519+
// CHECK: %[[ABS:.*]] = tosa.abs %[[INPUT_TENSOR]] : (tensor<f32>) -> tensor<f32>
520+
// CHECK: %[[POW:.*]] = tosa.pow %[[ABS]], %[[ORD]] : (tensor<f32>, tensor<f32>) -> tensor<f32>
521+
// CHECK-NOT: tosa.reduce_sum
522+
// CHECK: %[[IDENTITY:.*]] = tosa.identity %[[POW]] : (tensor<f32>) -> tensor<f32>
523+
// CHECK: %[[RECIPROCAL:.*]] = tosa.reciprocal %[[ORD]] : (tensor<f32>) -> tensor<f32>
524+
// CHECK: %[[RESULT_TENSOR:.*]] = tosa.pow %[[IDENTITY]], %[[RECIPROCAL]] : (tensor<f32>, tensor<f32>) -> tensor<f32>
525+
// CHECK: %[[RESULT:.*]] = torch_c.from_builtin_tensor %[[RESULT_TENSOR]] : tensor<f32> -> !torch.vtensor<[],f32>
526+
// CHECK: return %[[RESULT]] : !torch.vtensor<[],f32>
527+
// CHECK: }
528+
func.func @test_linalg_vector_norm_scalar_negative_dim(%arg0: !torch.vtensor<[],f32>) -> !torch.vtensor<[],f32> {
529+
%ord = torch.constant.float 3.000000e+00
530+
%dim = torch.constant.int -1
531+
%keepdims = torch.constant.bool false
532+
%dtype = torch.constant.none
533+
%dims = torch.prim.ListConstruct %dim : (!torch.int) -> !torch.list<int>
534+
%0 = torch.aten.linalg_vector_norm %arg0, %ord, %dims, %keepdims, %dtype : !torch.vtensor<[],f32>, !torch.float, !torch.list<int>, !torch.bool, !torch.none -> !torch.vtensor<[],f32>
535+
return %0 : !torch.vtensor<[],f32>
536+
}
537+
538+
// -----
539+
408540
// CHECK-LABEL: func.func @test_reduce_sum$basic(
409541
// CHECK-SAME: %[[VAL_0:.*]]: !torch.vtensor<[?,?,?,?],f32>) -> !torch.vtensor<[1],f32> {
410542
// CHECK: %[[VAL_1:.*]] = torch_c.to_builtin_tensor %[[VAL_0]] : !torch.vtensor<[?,?,?,?],f32> -> tensor<?x?x?x?xf32>

0 commit comments

Comments
 (0)