-
-
Save jpienaar/9598339b504157b189c3a3c38314a703 to your computer and use it in GitHub Desktop.
Checking ranges
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i = 0; | |
for (auto it : asmState.getOpDefs()) { | |
const char *startOp = it.scopeLoc.Start.getPointer(); | |
const char *endOp = it.scopeLoc.End.getPointer(); | |
for (auto res : it.resultGroups) { | |
SMRange range = res.definition.loc; | |
startOp = std::min(startOp, range.Start.getPointer()); | |
} | |
rewriteBuffer.InsertText(startOp - start, ("π<" + Twine(i) + ">").str()); | |
rewriteBuffer.InsertText(endOp - start, ("<" + Twine(i) + ">π").str()); | |
++i; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Two dynamic shapes: one of direct shape.shape_of(arg) and the other. | |
π<15>func.func @two_dynamic_one_direct_shape(%arg0: tensor<?x4x?xf32>, %arg1: tensor<2x4x?xf32>) -> tensor<?x4x?xf32> { | |
// SHAPE-DAG: Shape for {{.*}} = "test.abs"({{.*}}> :: @shape_cal_0(<block argument> of type 'tensor<?x4x?xf32>' at index: 0) | |
// SHAPE-DAG: Shape for {{.*}} = "test.concat"({{.*}}> :: @shape_cal_1(<block argument> of type 'tensor<?x4x?xf32>' at index: 0) | |
π<0>%c2 = arith.constant 2 : index | |
<0>ππ<1>%c0 = arith.constant 0 : index | |
// Bar | |
<1>ππ<2>%c4 = arith.constant 4 : index | |
// Foo | |
<2>ππ<3>%0 = shape.shape_of %arg0 : tensor<?x4x?xf32> -> tensor<3xindex> | |
<3>ππ<4>%1 = shape.get_extent %0, %c2 : tensor<3xindex>, index -> index | |
<4>ππ<5>%2 = "test.abs"(%arg0) : (tensor<?x4x?xf32>) -> tensor<?x4x?xf32> | |
<5>ππ<6>%3 = shape.with_shape %2, %0 : tensor<?x4x?xf32>, tensor<3xindex> | |
<6>ππ<7>%4 = shape.value_of %3 : tensor<?x4x?xf32> | |
<7>ππ<8>%5 = "test.concat"(%4, %arg1) {axis = 0 : i64} : (tensor<?x4x?xf32>, tensor<2x4x?xf32>) -> tensor<?x4x?xf32> | |
<8>ππ<9>%6 = shape.get_extent %0, %c0 : tensor<3xindex>, index -> index | |
<9>ππ<10>%7 = arith.addi %6, %c2 : index | |
<10>ππ<11>%8 = shape.from_extents %7, %c4, %1 : index, index, index | |
<11>ππ<12>%9 = shape.with_shape %5, %8 : tensor<?x4x?xf32>, !shape.shape | |
<12>ππ<13>%10 = shape.value_of %9 : tensor<?x4x?xf32> | |
<13>ππ<14>return %10 : tensor<?x4x?xf32> | |
<14>π} | |
<15>π |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Two dynamic shapes: one of direct shape.shape_of(arg) and the other. | |
π<15>func.func @two_dynamic_one_direct_shape(%arg0: tensor<?x4x?xf32>, %arg1: tensor<2x4x?xf32>) -> tensor<?x4x?xf32> { | |
// SHAPE-DAG: Shape for {{.*}} = "test.abs"({{.*}}> :: @shape_cal_0(<block argument> of type 'tensor<?x4x?xf32>' at index: 0) | |
// SHAPE-DAG: Shape for {{.*}} = "test.concat"({{.*}}> :: @shape_cal_1(<block argument> of type 'tensor<?x4x?xf32>' at index: 0) | |
π<0>%c2 = arith.constant 2 : index<0>π | |
π<1>%c0 = arith.constant 0 : index<1>π | |
// Bar | |
π<2>%c4 = arith.constant 4 : index<2>π | |
// Foo | |
π<3>%0 = shape.shape_of %arg0 : tensor<?x4x?xf32> -> tensor<3xindex><3>π | |
π<4>%1 = shape.get_extent %0, %c2 : tensor<3xindex>, index -> index<4>π | |
π<5>%2 = "test.abs"(%arg0) : (tensor<?x4x?xf32>) -> tensor<?x4x?xf32><5>π | |
π<6>%3 = shape.with_shape %2, %0 : tensor<?x4x?xf32>, tensor<3xindex><6>π | |
π<7>%4 = shape.value_of %3 : tensor<?x4x?xf32><7>π | |
π<8>%5 = "test.concat"(%4, %arg1) {axis = 0 : i64} : (tensor<?x4x?xf32>, tensor<2x4x?xf32>) -> tensor<?x4x?xf32><8>π | |
π<9>%6 = shape.get_extent %0, %c0 : tensor<3xindex>, index -> index<9>π | |
π<10>%7 = arith.addi %6, %c2 : index<10>π | |
π<11>%8 = shape.from_extents %7, %c4, %1 : index, index, index<11>π | |
π<12>%9 = shape.with_shape %5, %8 : tensor<?x4x?xf32>, !shape.shape | |
π<13>%10<12>π = shape.value_of %9 : tensor<?x4x?xf32><13>π | |
π<14>return %10 : tensor<?x4x?xf32><14>π | |
}<15>π |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment