Skip to content

Commit 6ae7af5

Browse files
authored
Merge pull request #547 from Xilinx/bump_to_09af3b60
[AutoBump] Merge with 09af3b6 (Jan 14) (154)
2 parents 9f5cca3 + 54b73be commit 6ae7af5

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

CMakeLists.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ option(TORCH_MLIR_ENABLE_STABLEHLO "Add stablehlo dialect" ON)
4343
if(TORCH_MLIR_ENABLE_STABLEHLO)
4444
add_definitions(-DTORCH_MLIR_ENABLE_STABLEHLO)
4545
endif()
46+
# It is possible that both stablehlo and torch_mlir projects are used in some compiler project.
47+
# In this case, we don't want to use stablehlo that is downloaded by torch_mlir (in external/stablehlo)
48+
# folder but instead want to use stablehlo that is part of top level compiler project.
49+
# With TORCH_MLIR_USE_EXTERNAL_STABLEHLO enables, it is assumed that top level compiler project makes
50+
# stablehlo targets AND includes available (for example with `add_subdirectory` and `include_directories`).
51+
option(TORCH_MLIR_USE_EXTERNAL_STABLEHLO "Use stablehlo from top level project" OFF)
4652

4753
option(TORCH_MLIR_OUT_OF_TREE_BUILD "Specifies an out of tree build" OFF)
4854

@@ -142,7 +148,8 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
142148

143149
function(torch_mlir_target_includes target)
144150
set(_dirs
145-
$<BUILD_INTERFACE:${MLIR_INCLUDE_DIRS}>
151+
$<BUILD_INTERFACE:${MLIR_INCLUDE_DIR}>
152+
$<BUILD_INTERFACE:${MLIR_GENERATED_INCLUDE_DIR}>
146153
$<BUILD_INTERFACE:${TORCH_MLIR_SOURCE_DIR}/include>
147154
$<BUILD_INTERFACE:${TORCH_MLIR_BINARY_DIR}/include>
148155
)
@@ -232,7 +239,8 @@ endif()
232239
# Getting this wrong results in building large parts of the stablehlo
233240
# project that we don't actually depend on. Further some of those parts
234241
# do not even compile on all platforms.
235-
if (TORCH_MLIR_ENABLE_STABLEHLO)
242+
# Only configure StableHLO if it isn't provided from a top-level project
243+
if (TORCH_MLIR_ENABLE_STABLEHLO AND NOT TORCH_MLIR_USE_EXTERNAL_STABLEHLO)
236244
set(STABLEHLO_BUILD_EMBEDDED ON)
237245
set(STABLEHLO_ENABLE_BINDINGS_PYTHON ON)
238246
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/externals/stablehlo

include/torch-mlir/Dialect/Torch/IR/TorchOps.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,15 @@ def Torch_SymbolicIntOp : Torch_Op<"symbolic_int", [Pure]> {
13611361
%0 = torch.symbolic_int "s0" {min_val = 5, max_val = 10} : !torch.int
13621362
%1 = torch.symbolic_int "s1" {min_val = 2, max_val = 20} : !torch.int
13631363
```
1364+
1365+
In this case, we see that `s0` has the range [5, 10] and `s1` has the
1366+
range [2, 20]. When unspecified, the range constraints feeding in from
1367+
TorchDynamo default to [0, INT_MAX] (or [2, INT_MAX] in older PyTorch
1368+
releases). In either case, the interpretation (as specified by TorchDynamo)
1369+
is that the dynamic dimension is assumed to be not 0 or 1. This is not a
1370+
bug, and does not necessarily mean that the exported program will not work
1371+
for dimensions 0 or 1. For an in-depth discussion of this topic, see
1372+
[The 0/1 Specialization Problem](https://docs.google.com/document/d/16VPOa3d-Liikf48teAOmxLc92rgvJdfosIy-yoT38Io/edit?fbclid=IwAR3HNwmmexcitV0pbZm_x1a4ykdXZ9th_eJWK-3hBtVgKnrkmemz6Pm5jRQ#heading=h.ez923tomjvyk).
13641373
}];
13651374
let arguments = (ins
13661375
StrAttr:$symbol_name,

0 commit comments

Comments
 (0)