-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into DIP_jpeg
- Loading branch information
Showing
12 changed files
with
182 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
; extended FROSTT format | ||
2 4 | ||
4 4 | ||
1 2 30 | ||
1 3 4 | ||
3 3 4 | ||
4 3 7 |
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
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
52 changes: 52 additions & 0 deletions
52
examples/MLIRSparseTensor/sparse-tensor-vectorization.mlir
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#SparseVector = #sparse_tensor.encoding<{ | ||
dimLevelType = ["compressed"] | ||
}> | ||
|
||
#trait_mul = { | ||
indexing_maps = [ | ||
affine_map<(i) -> (i)>, // a | ||
affine_map<(i) -> (i)>, // b | ||
affine_map<(i) -> (i)> // x (out) | ||
], | ||
iterator_types = ["parallel"], | ||
doc = "x(i) = a(i) * b(i)" | ||
} | ||
|
||
// Example for parallel loop vectorization | ||
func.func @sparse_mul(%arga: tensor<1024xf32, #SparseVector>, | ||
%argb: tensor<1024xf32>, | ||
%argx: tensor<1024xf32>) -> tensor<1024xf32> { | ||
%0 = linalg.generic #trait_mul | ||
ins(%arga, %argb: tensor<1024xf32, #SparseVector>, tensor<1024xf32>) | ||
outs(%argx: tensor<1024xf32>) { | ||
^bb(%a: f32, %b: f32, %x: f32): | ||
%0 = arith.mulf %a, %b : f32 | ||
linalg.yield %0 : f32 | ||
} -> tensor<1024xf32> | ||
return %0 : tensor<1024xf32> | ||
} | ||
|
||
#trait_reduction = { | ||
indexing_maps = [ | ||
affine_map<(i) -> (i)>, // a | ||
affine_map<(i) -> (i)>, // b | ||
affine_map<(i) -> ()> // x (out) | ||
], | ||
iterator_types = ["reduction"], | ||
doc = "x += a(i) * b(i)" | ||
} | ||
|
||
// Example for reduction loop vectorization | ||
func.func @sparse_reduction(%arga: tensor<1024xf32, #SparseVector>, | ||
%argb: tensor<1024xf32>, | ||
%argx: tensor<f32>) -> tensor<f32> { | ||
%0 = linalg.generic #trait_reduction | ||
ins(%arga, %argb: tensor<1024xf32, #SparseVector>, tensor<1024xf32>) | ||
outs(%argx: tensor<f32>) { | ||
^bb(%a: f32, %b: f32, %x: f32): | ||
%0 = arith.mulf %a, %b : f32 | ||
%1 = arith.addf %x, %0 : f32 | ||
linalg.yield %1 : f32 | ||
} -> tensor<f32> | ||
return %0 : tensor<f32> | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--pre --extra-index-url https://download.pytorch.org/whl/nightly/cpu | ||
torch == 2.2.0.dev20231015+cpu | ||
transformers == 4.33.1 |