Skip to content

Commit

Permalink
xxx-test
Browse files Browse the repository at this point in the history
  • Loading branch information
ingomueller-net committed Jan 27, 2023
1 parent 28449d0 commit 22dc634
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: iterators-opt %s \
// RUN: -convert-iterators-to-llvm \
// RUN: -convert-states-to-llvm \
// RUN: -convert-func-to-llvm \
// RUN: -convert-scf-to-cf -convert-cf-to-llvm \
// RUN: | mlir-cpu-runner -e main -entry-point-result=void \
// RUN: | FileCheck %s

!struct_i32 = !llvm.struct<(i32)>

func.func private @tensor_to_struct(%input : tensor<1xi32>) -> !struct_i32 {
%zero = arith.constant 0 : index
%i = tensor.extract %input[%zero] : tensor<1xi32>
%undef = llvm.mlir.undef : !struct_i32
%result = llvm.insertvalue %i, %undef[0] : !struct_i32
return %result : !struct_i32
}

func.func @main() {
%tensor = arith.constant dense<[1, 2, 3, 4]> : tensor<4xi32>
%stream = iterators.tensor_to_stream %tensor :
tensor<4xi32> to !iterators.stream<tensor<1xi32>>
%mapped = "iterators.map"(%stream) {mapFuncRef = @tensor_to_struct}
: (!iterators.stream<tensor<1xi32>>) -> (!iterators.stream<!struct_i32>)
"iterators.sink"(%mapped) : (!iterators.stream<!struct_i32>) -> ()
// CHECK: (1)
// CHECK: (2)
// CHECK: (3)
// CHECK: (4)
return
}

0 comments on commit 22dc634

Please sign in to comment.