@@ -133,3 +133,47 @@ func.func @aten.permute$identity_permutation(%arg0: !torch.vtensor<[64,32,16,8,4
133133 %1 = torch.aten.permute %arg0 , %0 : !torch.vtensor <[64 ,32 ,16 ,8 ,4 ],f32 >, !torch.list <int > -> !torch.vtensor <[64 ,32 ,16 ,8 ,4 ],f32 >
134134 return %1 : !torch.vtensor <[64 ,32 ,16 ,8 ,4 ],f32 >
135135}
136+
137+ // -----
138+
139+ // CHECK-LABEL: func.func @torch.aten.slice$end_int64_max_dynamic(
140+ // CHECK-SAME: %[[ARG0:.*]]: !torch.vtensor<[4,?],f32>
141+ // CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
142+ // CHECK-DAG: %[[T:.*]] = torch_c.to_builtin_tensor %[[ARG0]] : !torch.vtensor<[4,?],f32> -> tensor<4x?xf32>
143+ // CHECK: %[[DIM:.*]] = tensor.dim %[[T]], %[[C1]] : tensor<4x?xf32>
144+ // COM: No INT64_MAX sentinel is materialized: the end resolves to %[[DIM]], so
145+ // COM: the slice extent is computed as (dim - start) directly off the queried
146+ // COM: dim, with no min(INT64_MAX, dim) clamp in between.
147+ // CHECK-NOT: 9223372036854775807
148+ // CHECK: arith.subi %[[DIM]], %{{.*}} : index
149+ // CHECK: %[[SLICE:.*]] = tensor.extract_slice %[[T]][0, %{{.*}}] [4, %{{.*}}] [1, 1] : tensor<4x?xf32> to tensor<4x?xf32>
150+ // CHECK: torch_c.from_builtin_tensor %[[SLICE]]
151+ func.func @torch.aten.slice$end_int64_max_dynamic (%arg0: !torch.vtensor <[4 ,?],f32 >) -> !torch.vtensor <[4 ,?],f32 > {
152+ %int1 = torch.constant.int 1
153+ %int2 = torch.constant.int 2
154+ %intmax = torch.constant.int 9223372036854775807
155+ %0 = torch.aten.slice.Tensor %arg0 , %int1 , %int2 , %intmax , %int1 : !torch.vtensor <[4 ,?],f32 >, !torch.int , !torch.int , !torch.int , !torch.int -> !torch.vtensor <[4 ,?],f32 >
156+ return %0 : !torch.vtensor <[4 ,?],f32 >
157+ }
158+
159+ // -----
160+
161+ // Same INT64_MAX end sentinel, but with step=2: the end still resolves to the
162+ // dim (no sentinel constant), and the strided size is (dim - start) floor-div
163+ // step.
164+ // CHECK-LABEL: func.func @torch.aten.slice$end_int64_max_dynamic_step2(
165+ // CHECK-SAME: %[[ARG0:.*]]: !torch.vtensor<[4,?],f32>
166+ // CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index
167+ // CHECK-DAG: %[[T:.*]] = torch_c.to_builtin_tensor %[[ARG0]] : !torch.vtensor<[4,?],f32> -> tensor<4x?xf32>
168+ // CHECK: %[[DIM:.*]] = tensor.dim %[[T]], %[[C1]] : tensor<4x?xf32>
169+ // CHECK-NOT: 9223372036854775807
170+ // CHECK: %[[LEN:.*]] = arith.subi %[[DIM]], %{{.*}} : index
171+ // CHECK: arith.floordivsi %{{.*}}, %{{.*}} : index
172+ // CHECK: tensor.extract_slice %[[T]][0, %{{.*}}] [4, %{{.*}}] [1, 2] : tensor<4x?xf32> to tensor<4x?xf32>
173+ func.func @torch.aten.slice$end_int64_max_dynamic_step2 (%arg0: !torch.vtensor <[4 ,?],f32 >) -> !torch.vtensor <[4 ,?],f32 > {
174+ %int1 = torch.constant.int 1
175+ %int2 = torch.constant.int 2
176+ %intmax = torch.constant.int 9223372036854775807
177+ %0 = torch.aten.slice.Tensor %arg0 , %int1 , %int2 , %intmax , %int2 : !torch.vtensor <[4 ,?],f32 >, !torch.int , !torch.int , !torch.int , !torch.int -> !torch.vtensor <[4 ,?],f32 >
178+ return %0 : !torch.vtensor <[4 ,?],f32 >
179+ }
0 commit comments