├── .github └── workflows │ ├── env.Dockerfile │ ├── env.yml │ └── run-test.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake └── CPM.cmake ├── src ├── abstractops.cpp ├── abstractops.h ├── analysis.cpp ├── analysis.h ├── debug.cpp ├── debug.h ├── encode.cpp ├── encode.h ├── function.cpp ├── function.h ├── main.cpp ├── memory.cpp ├── memory.h ├── opts.h ├── print.cpp ├── print.h ├── simplevalue.h ├── smt.cpp ├── smt.h ├── smtmatchers.h ├── state.cpp ├── state.h ├── utils.cpp ├── utils.h ├── value.cpp ├── value.h ├── vcgen.cpp └── vcgen.h ├── tests ├── CMakeLists.txt ├── README.md ├── lit.cfg.py ├── lit.site.cfg.py.in ├── lit │ ├── BooleanExpression.py │ ├── LitConfig.py │ ├── LitTestCase.py │ ├── ProgressBar.py │ ├── ShCommands.py │ ├── ShUtil.py │ ├── Test.py │ ├── TestRunner.py │ ├── TestingConfig.py │ ├── __init__.py │ ├── builtin_commands │ │ ├── __init__.py │ │ ├── cat.py │ │ └── diff.py │ ├── cl_arguments.py │ ├── discovery.py │ ├── display.py │ ├── formats │ │ ├── __init__.py │ │ ├── base.py │ │ ├── googletest.py │ │ ├── mlirtest.py │ │ └── shtest.py │ ├── llvm │ │ ├── __init__.py │ │ ├── config.py │ │ └── subst.py │ ├── main.py │ ├── reports.py │ ├── run.py │ ├── util.py │ └── worker.py ├── litmus │ ├── abstraction │ │ ├── dot.src.mlir │ │ ├── dot.tgt.mlir │ │ ├── dot_concat.src.mlir │ │ ├── dot_concat.tgt.mlir │ │ ├── dot_concat_multiset.src.mlir │ │ ├── dot_concat_multiset.tgt.mlir │ │ ├── dotint.src.mlir │ │ └── dotint.tgt.mlir │ ├── affine-ops │ │ ├── add.src.mlir │ │ ├── add.tgt.mlir │ │ ├── mul.src.mlir │ │ └── mul.tgt.mlir │ ├── arith-ops │ │ ├── addi.src.mlir │ │ ├── addi.tgt.mlir │ │ ├── addi_tensor.src.mlir │ │ ├── addi_tensor.tgt.mlir │ │ ├── cmpi_index.src.mlir │ │ ├── cmpi_index.tgt.mlir │ │ ├── extsi.src.mlir │ │ ├── extsi.tgt.mlir │ │ ├── extui.src.mlir │ │ ├── extui.tgt.mlir │ │ ├── index_cast.src.mlir │ │ ├── index_cast.tgt.mlir │ │ ├── index_cast_tensor.src.mlir │ │ ├── index_cast_tensor.tgt.mlir │ │ ├── muli.src.mlir │ │ ├── muli.tgt.mlir │ │ ├── negf.src.mlir │ │ ├── negf.tgt.mlir │ │ ├── shift.src.mlir │ │ ├── shift.tgt.mlir │ │ ├── shli_index_ub.src.mlir │ │ ├── shli_index_ub.tgt.mlir │ │ ├── shli_tensor_ub.src.mlir │ │ ├── shli_tensor_ub.tgt.mlir │ │ ├── shli_ub.src.mlir │ │ ├── shli_ub.tgt.mlir │ │ ├── shrsi_ub.src.mlir │ │ ├── shrsi_ub.tgt.mlir │ │ ├── shrui_ub.src.mlir │ │ ├── shrui_ub.tgt.mlir │ │ ├── subf-bad.src.mlir │ │ ├── subf-bad.tgt.mlir │ │ ├── subf.src.mlir │ │ ├── subf.tgt.mlir │ │ ├── trunci.src.mlir │ │ ├── trunci.tgt.mlir │ │ ├── xori.src.mlir │ │ └── xori.tgt.mlir │ ├── bufferization-ops │ │ ├── buffer_cast.src.mlir │ │ ├── buffer_cast.tgt.mlir │ │ ├── buffer_cast_i8.src.mlir │ │ ├── buffer_cast_i8.tgt.mlir │ │ ├── buffer_cast_zero.src.mlir │ │ ├── buffer_cast_zero.tgt.mlir │ │ ├── bufferize-select.src.mlir │ │ ├── bufferize-select.tgt.mlir │ │ ├── bufferize-select2.src.mlir │ │ ├── bufferize-select2.tgt.mlir │ │ ├── clone-no-introduce.src.mlir │ │ ├── clone-no-introduce.tgt.mlir │ │ ├── clone-removal.src.mlir │ │ ├── clone-removal.tgt.mlir │ │ ├── clone.src.mlir │ │ ├── clone.tgt.mlir │ │ ├── convolution.src.mlir │ │ ├── convolution.tgt.mlir │ │ ├── copy.src.mlir │ │ ├── copy.tgt.mlir │ │ ├── copy_i32.src.mlir │ │ ├── copy_i32.tgt.mlir │ │ ├── fill-memref-bad.src.mlir │ │ ├── fill-memref-bad.tgt.mlir │ │ ├── fill-memref.src.mlir │ │ ├── fill-memref.tgt.mlir │ │ ├── tensor_load.src.mlir │ │ ├── tensor_load.tgt.mlir │ │ ├── var_buffer_cast.src.mlir │ │ └── var_buffer_cast.tgt.mlir │ ├── cexprint │ │ ├── fp.src.mlir │ │ ├── fp.tgt.mlir │ │ ├── reverse.src.mlir │ │ └── reverse.tgt.mlir │ ├── diagnostics │ │ ├── assign-random.src.mlir │ │ ├── assign-random.tgt.mlir │ │ ├── memref-missing-bugs.src.mlir │ │ ├── memref-missing-bugs.tgt.mlir │ │ ├── store-bad.src.mlir │ │ └── store-bad.tgt.mlir │ ├── fp-ops │ │ ├── add_assoc.src.mlir │ │ ├── add_assoc.tgt.mlir │ │ ├── cmp_const-bad.src.mlir │ │ ├── cmp_const-bad.tgt.mlir │ │ ├── cmp_const.src.mlir │ │ ├── cmp_const.tgt.mlir │ │ ├── cmp_fixed.src.mlir │ │ ├── cmp_fixed.tgt.mlir │ │ ├── cmp_inverse.src.mlir │ │ ├── cmp_inverse.tgt.mlir │ │ ├── cmp_nan.src.mlir │ │ ├── cmp_nan.tgt.mlir │ │ ├── cmp_ord-bad.src.mlir │ │ ├── cmp_ord-bad.tgt.mlir │ │ ├── cmp_zero.src.mlir │ │ ├── cmp_zero.tgt.mlir │ │ ├── comm_add.src.mlir │ │ ├── comm_add.tgt.mlir │ │ ├── comm_add_const.src.mlir │ │ ├── comm_add_const.tgt.mlir │ │ ├── comm_add_double.src.mlir │ │ ├── comm_add_double.tgt.mlir │ │ ├── comm_div-bad.src.mlir │ │ ├── comm_div-bad.tgt.mlir │ │ ├── comm_div_const-bad.src.mlir │ │ ├── comm_div_const-bad.tgt.mlir │ │ ├── comm_mul.src.mlir │ │ ├── comm_mul.tgt.mlir │ │ ├── comm_mul_const.src.mlir │ │ ├── comm_mul_const.tgt.mlir │ │ ├── ext-bad.src.mlir │ │ ├── ext-bad.tgt.mlir │ │ ├── ext_cmp.src.mlir │ │ ├── ext_cmp.tgt.mlir │ │ ├── ext_const.src.mlir │ │ ├── ext_const.tgt.mlir │ │ ├── ext_const_single_ext-bad.src.mlir │ │ ├── ext_const_single_ext-bad.tgt.mlir │ │ ├── ext_const_single_ext.src.mlir │ │ ├── ext_const_single_ext.tgt.mlir │ │ ├── ext_inf.src.mlir │ │ ├── ext_inf.tgt.mlir │ │ ├── ext_nan.src.mlir │ │ ├── ext_nan.tgt.mlir │ │ ├── ident_add.src.mlir │ │ ├── ident_add.tgt.mlir │ │ ├── ident_add_const.src.mlir │ │ ├── ident_add_const.tgt.mlir │ │ ├── ident_add_double.src.mlir │ │ ├── ident_add_double.tgt.mlir │ │ ├── ident_div.src.mlir │ │ ├── ident_div.tgt.mlir │ │ ├── ident_div_const.src.mlir │ │ ├── ident_div_const.tgt.mlir │ │ ├── ident_mul.src.mlir │ │ ├── ident_mul.tgt.mlir │ │ ├── ident_mul_const.src.mlir │ │ ├── ident_mul_const.tgt.mlir │ │ ├── inf_add-bad.src.mlir │ │ ├── inf_add-bad.tgt.mlir │ │ ├── inf_add_conflict.src.mlir │ │ ├── inf_add_conflict.tgt.mlir │ │ ├── inf_add_conflict_double.src.mlir │ │ ├── inf_add_conflict_double.tgt.mlir │ │ ├── inf_add_const.src.mlir │ │ ├── inf_add_const.tgt.mlir │ │ ├── inf_add_const_double.src.mlir │ │ ├── inf_add_const_double.tgt.mlir │ │ ├── inf_add_const_neg.src.mlir │ │ ├── inf_add_const_neg.tgt.mlir │ │ ├── inf_add_const_neg_double.src.mlir │ │ ├── inf_add_const_neg_double.tgt.mlir │ │ ├── inf_add_double-bad.src.mlir │ │ ├── inf_add_double-bad.tgt.mlir │ │ ├── inf_div_const.src.mlir │ │ ├── inf_div_const.tgt.mlir │ │ ├── inf_div_const_neg.src.mlir │ │ ├── inf_div_const_neg.tgt.mlir │ │ ├── inf_div_inf.src.mlir │ │ ├── inf_div_inf.tgt.mlir │ │ ├── inf_div_zero.src.mlir │ │ ├── inf_div_zero.tgt.mlir │ │ ├── inf_mul_conflict.src.mlir │ │ ├── inf_mul_conflict.tgt.mlir │ │ ├── inf_mul_const.src.mlir │ │ ├── inf_mul_const.tgt.mlir │ │ ├── inf_mul_const_neg.src.mlir │ │ ├── inf_mul_const_neg.tgt.mlir │ │ ├── inf_mul_zero.src.mlir │ │ ├── inf_mul_zero.tgt.mlir │ │ ├── nan_add.src.mlir │ │ ├── nan_add.tgt.mlir │ │ ├── nan_add_const.src.mlir │ │ ├── nan_add_const.tgt.mlir │ │ ├── nan_add_const_double.src.mlir │ │ ├── nan_add_const_double.tgt.mlir │ │ ├── nan_add_double.src.mlir │ │ ├── nan_add_double.tgt.mlir │ │ ├── nan_div.src.mlir │ │ ├── nan_div.tgt.mlir │ │ ├── nan_mul.src.mlir │ │ ├── nan_mul.tgt.mlir │ │ ├── neg_add-bad.src.mlir │ │ ├── neg_add-bad.tgt.mlir │ │ ├── neg_add_const.src.mlir │ │ ├── neg_add_const.tgt.mlir │ │ ├── neg_add_double-bad.src.mlir │ │ ├── neg_add_double-bad.tgt.mlir │ │ ├── neg_const-bad.src.mlir │ │ ├── neg_const-bad.tgt.mlir │ │ ├── neg_const.src.mlir │ │ ├── neg_const.tgt.mlir │ │ ├── self_div_const.src.mlir │ │ ├── self_div_const.tgt.mlir │ │ ├── trunc_cmpf_eq-bad.src.mlir │ │ ├── trunc_cmpf_eq-bad.tgt.mlir │ │ ├── trunc_cmpf_gt-bad.src.mlir │ │ ├── trunc_cmpf_gt-bad.tgt.mlir │ │ ├── trunc_cmpf_lt-bad.src.mlir │ │ ├── trunc_cmpf_lt-bad.tgt.mlir │ │ ├── trunc_cmpf_ne-bad.src.mlir │ │ ├── trunc_cmpf_ne-bad.tgt.mlir │ │ ├── trunc_const-bad.src.mlir │ │ ├── trunc_const-bad.tgt.mlir │ │ ├── trunc_const.src.mlir │ │ ├── trunc_const.tgt.mlir │ │ ├── trunc_const_ceiling.src.mlir │ │ ├── trunc_const_ceiling.tgt.mlir │ │ ├── trunc_const_flooring.src.mlir │ │ ├── trunc_const_flooring.tgt.mlir │ │ ├── trunc_const_rounding-bad.src.mlir │ │ ├── trunc_const_rounding-bad.tgt.mlir │ │ ├── trunc_const_rounding.src.mlir │ │ ├── trunc_const_rounding.tgt.mlir │ │ ├── trunc_const_single_trunc-bad.src.mlir │ │ ├── trunc_const_single_trunc-bad.tgt.mlir │ │ ├── trunc_const_single_trunc.src.mlir │ │ ├── trunc_const_single_trunc.tgt.mlir │ │ ├── trunc_const_to_inf.src.mlir │ │ ├── trunc_const_to_inf.tgt.mlir │ │ ├── trunc_inf.src.mlir │ │ ├── trunc_inf.tgt.mlir │ │ ├── trunc_nan.src.mlir │ │ ├── trunc_nan.tgt.mlir │ │ ├── zero_div_const.src.mlir │ │ ├── zero_div_const.tgt.mlir │ │ ├── zero_div_zero.src.mlir │ │ └── zero_div_zero.tgt.mlir │ ├── func-ops │ │ ├── cast_to_dyn-bad.src.mlir │ │ ├── cast_to_dyn-bad.tgt.mlir │ │ ├── fn_arg_dims.src.mlir │ │ ├── fn_arg_dims.tgt.mlir │ │ ├── fn_arg_dims_multiple.src.mlir │ │ ├── fn_arg_dims_multiple.tgt.mlir │ │ ├── no_fn_arg_dims-bad.src.mlir │ │ ├── no_fn_arg_dims-bad.tgt.mlir │ │ ├── scalar.src.mlir │ │ ├── scalar.tgt.mlir │ │ ├── scalar_chain-bad.src.mlir │ │ ├── scalar_chain-bad.tgt.mlir │ │ ├── scalar_comm-bad.src.mlir │ │ ├── scalar_comm-bad.tgt.mlir │ │ ├── tensor-bad.src.mlir │ │ ├── tensor-bad.tgt.mlir │ │ ├── tensor.src.mlir │ │ └── tensor.tgt.mlir │ ├── linalg-loops │ │ ├── convert-elementwise-cmpf.src.mlir │ │ ├── convert-elementwise-cmpf.tgt.mlir │ │ ├── convert-elementwise-select.src.mlir │ │ ├── convert-elementwise-select.tgt.mlir │ │ ├── convert-elementwise-select2.src.mlir │ │ ├── convert-elementwise-select2.tgt.mlir │ │ ├── convert-elementwise-select3.src.mlir │ │ ├── convert-elementwise-select3.tgt.mlir │ │ ├── empty.src.mlir │ │ ├── empty.tgt.mlir │ │ ├── generic-loopbound.src.mlir │ │ ├── generic-loopbound.tgt.mlir │ │ ├── memref-int-bad.src.mlir │ │ ├── memref-int-bad.tgt.mlir │ │ ├── memref-int-ub.src.mlir │ │ ├── memref-int-ub.tgt.mlir │ │ ├── memref-int.src.mlir │ │ ├── memref-int.tgt.mlir │ │ ├── mult_result.src.mlir │ │ ├── mult_result.tgt.mlir │ │ ├── nested.src.mlir │ │ ├── nested.tgt.mlir │ │ ├── output-value-bad.src.mlir │ │ ├── output-value-bad.tgt.mlir │ │ ├── output-value.src.mlir │ │ ├── output-value.tgt.mlir │ │ ├── simple_cmpf.src.mlir │ │ ├── simple_cmpf.tgt.mlir │ │ ├── sum-assoc-bad.src.mlir │ │ ├── sum-assoc-bad.tgt.mlir │ │ ├── sum-assoc-f64.src.mlir │ │ ├── sum-assoc-f64.tgt.mlir │ │ ├── sum-assoc.src.mlir │ │ ├── sum-assoc.tgt.mlir │ │ ├── sum-bad.src.mlir │ │ ├── sum-bad.tgt.mlir │ │ ├── sum-int-unroll.src.mlir │ │ ├── sum-int-unroll.tgt.mlir │ │ ├── sum-mul.src.mlir │ │ ├── sum-mul.tgt.mlir │ │ ├── sum-unit-tensor-ub.src.mlir │ │ ├── sum-unit-tensor-ub.tgt.mlir │ │ ├── sum-unit-tensor.src.mlir │ │ ├── sum-unit-tensor.tgt.mlir │ │ ├── sum-with-identity-assoc.src.mlir │ │ ├── sum-with-identity-assoc.tgt.mlir │ │ ├── sum-with-identity.src.mlir │ │ └── sum-with-identity.tgt.mlir │ ├── linalg-ops │ │ ├── conv-uninit.src.mlir │ │ ├── conv-uninit.tgt.mlir │ │ ├── convolution_constfold.src.mlir │ │ ├── convolution_constfold.tgt.mlir │ │ ├── convolution_int.src.mlir │ │ ├── convolution_int.tgt.mlir │ │ ├── dot.src.mlir │ │ ├── dot.tgt.mlir │ │ ├── dot2.src.mlir │ │ ├── dot2.tgt.mlir │ │ ├── dot_assoc_varlen.src.mlir │ │ ├── dot_assoc_varlen.tgt.mlir │ │ ├── dot_associativity.src.mlir │ │ ├── dot_associativity.tgt.mlir │ │ ├── dot_associativity2.src.mlir │ │ ├── dot_associativity2.tgt.mlir │ │ ├── dot_associativity2_multiset.src.mlir │ │ ├── dot_associativity2_multiset.tgt.mlir │ │ ├── dot_associativity3_multiset.src.mlir │ │ ├── dot_associativity3_multiset.tgt.mlir │ │ ├── dot_commutative.src.mlir │ │ ├── dot_commutative.tgt.mlir │ │ ├── dot_constfold.src.mlir │ │ ├── dot_constfold.tgt.mlir │ │ ├── dot_rewrite_manually.src.mlir │ │ ├── dot_rewrite_manually.tgt.mlir │ │ ├── dot_rewrite_manually_assoc.src.mlir │ │ ├── dot_rewrite_manually_assoc.tgt.mlir │ │ ├── fill.src.mlir │ │ ├── fill.tgt.mlir │ │ ├── init_tensor.src.mlir │ │ ├── init_tensor.tgt.mlir │ │ ├── init_tensor_cast.src.mlir │ │ ├── init_tensor_cast.tgt.mlir │ │ ├── matmul-bad.src.mlir │ │ ├── matmul-bad.tgt.mlir │ │ ├── memref_matmul.src.mlir │ │ ├── memref_matmul.tgt.mlir │ │ ├── memref_matmul_bad.src.mlir │ │ ├── memref_matmul_bad.tgt.mlir │ │ ├── pooling_unsupported1.src.mlir │ │ ├── pooling_unsupported1.tgt.mlir │ │ ├── pooling_unsupported2.src.mlir │ │ └── pooling_unsupported2.tgt.mlir │ ├── math-ops │ │ ├── abs.src.mlir │ │ ├── abs.tgt.mlir │ │ ├── abs_mul.src.mlir │ │ ├── abs_mul.tgt.mlir │ │ ├── exp.src.mlir │ │ └── exp.tgt.mlir │ ├── memref-ops │ │ ├── alloc-alloc-noalias.src.mlir │ │ ├── alloc-alloc-noalias.tgt.mlir │ │ ├── alloc-arg-noalias-bad.src.mlir │ │ ├── alloc-arg-noalias-bad.tgt.mlir │ │ ├── alloc-arg-noalias.src.mlir │ │ ├── alloc-arg-noalias.tgt.mlir │ │ ├── alloc-bad.src.mlir │ │ ├── alloc-bad.tgt.mlir │ │ ├── alloc-varsize.src.mlir │ │ ├── alloc-varsize.tgt.mlir │ │ ├── alloc.src.mlir │ │ ├── alloc.tgt.mlir │ │ ├── alloca.src.mlir │ │ ├── alloca.tgt.mlir │ │ ├── collapse-shape.src.mlir │ │ ├── collapse-shape.tgt.mlir │ │ ├── copy-fill-bad.src.mlir │ │ ├── copy-fill-bad.tgt.mlir │ │ ├── copy-fill.src.mlir │ │ ├── copy-fill.tgt.mlir │ │ ├── dealloc-alloca.src.mlir │ │ ├── dealloc-alloca.tgt.mlir │ │ ├── dealloc-bad.src.mlir │ │ ├── dealloc-bad.tgt.mlir │ │ ├── dealloc-bad2.src.mlir │ │ ├── dealloc-bad2.tgt.mlir │ │ ├── dealloc-view-bad.src.mlir │ │ ├── dealloc-view-bad.tgt.mlir │ │ ├── dealloc.src.mlir │ │ ├── dealloc.tgt.mlir │ │ ├── dim.src.mlir │ │ ├── dim.tgt.mlir │ │ ├── expand-collapse-shape.src.mlir │ │ ├── expand-collapse-shape.tgt.mlir │ │ ├── expand-shape.src.mlir │ │ ├── expand-shape.tgt.mlir │ │ ├── global-arg-alias-bad.src.mlir │ │ ├── global-arg-alias-bad.tgt.mlir │ │ ├── global-const-bad.src.mlir │ │ ├── global-const-bad.tgt.mlir │ │ ├── global-const-intro.src.mlir │ │ ├── global-const-intro.tgt.mlir │ │ ├── global-const.src.mlir │ │ ├── global-const.tgt.mlir │ │ ├── global.src.mlir │ │ ├── global.tgt.mlir │ │ ├── load-intro-bad.src.mlir │ │ ├── load-intro-bad.tgt.mlir │ │ ├── load-intro-bad2.src.mlir │ │ ├── load-intro-bad2.tgt.mlir │ │ ├── memref-inputs-simple.src.mlir │ │ ├── memref-inputs-simple.tgt.mlir │ │ ├── nonidentity-layout-store-bad.src.mlir │ │ ├── nonidentity-layout-store-bad.tgt.mlir │ │ ├── nonidentity-layout-store.src.mlir │ │ ├── nonidentity-layout-store.tgt.mlir │ │ ├── subview_inbounds-noub.src.mlir │ │ ├── subview_inbounds-noub.tgt.mlir │ │ ├── subview_out_of_bounds.src.mlir │ │ ├── subview_out_of_bounds.tgt.mlir │ │ ├── subview_reduce_rank.src.mlir │ │ └── subview_reduce_rank.tgt.mlir │ ├── refinement │ │ ├── memory_mismatch.src.mlir │ │ ├── memory_mismatch.tgt.mlir │ │ ├── multiple-ret.src.mlir │ │ ├── multiple-ret.tgt.mlir │ │ ├── remove_memref_dealloc.src.mlir │ │ ├── remove_memref_dealloc.tgt.mlir │ │ ├── remove_memref_load.src.mlir │ │ ├── remove_memref_load.tgt.mlir │ │ ├── remove_memref_tensor_load.src.mlir │ │ ├── remove_memref_tensor_load.tgt.mlir │ │ ├── size-mismatch.src.mlir │ │ └── size-mismatch.tgt.mlir │ ├── sparsetensor-ops │ │ ├── convert.src.mlir │ │ ├── convert.tgt.mlir │ │ ├── ordering-doesnt-matter.src.mlir │ │ └── ordering-doesnt-matter.tgt.mlir │ ├── tensor-constant │ │ ├── dense-limit-verbose.src.mlir │ │ ├── dense-limit-verbose.tgt.mlir │ │ ├── dense-limit-verbose2.src.mlir │ │ ├── dense-limit-verbose2.tgt.mlir │ │ ├── dense-limit.src.mlir │ │ ├── dense-limit.tgt.mlir │ │ ├── dense-sparse-verbose.src.mlir │ │ ├── dense-sparse-verbose.tgt.mlir │ │ ├── dense-transpose-limit.src.mlir │ │ ├── dense-transpose-limit.tgt.mlir │ │ ├── dense.src.mlir │ │ ├── dense.tgt.mlir │ │ ├── dense_index.src.mlir │ │ ├── dense_index.tgt.mlir │ │ ├── dense_int.src.mlir │ │ ├── dense_int.tgt.mlir │ │ ├── reduction.src.mlir │ │ ├── reduction.tgt.mlir │ │ ├── sparse-limit.src.mlir │ │ ├── sparse-limit.tgt.mlir │ │ ├── sparse.src.mlir │ │ ├── sparse.tgt.mlir │ │ ├── sparse2.src.mlir │ │ ├── sparse2.tgt.mlir │ │ ├── sparse_bad.src.mlir │ │ ├── sparse_bad.tgt.mlir │ │ ├── sparse_int.src.mlir │ │ ├── sparse_int.tgt.mlir │ │ ├── sparse_zero.src.mlir │ │ ├── sparse_zero.tgt.mlir │ │ ├── transpose.src.mlir │ │ └── transpose.tgt.mlir │ ├── tensor-ops │ │ ├── cast-bad.src.mlir │ │ ├── cast-bad.tgt.mlir │ │ ├── cast.src.mlir │ │ ├── cast.tgt.mlir │ │ ├── cmp_const.src.mlir │ │ ├── cmp_const.tgt.mlir │ │ ├── cmp_inverse.src.mlir │ │ ├── cmp_inverse.tgt.mlir │ │ ├── dim.src.mlir │ │ ├── dim.tgt.mlir │ │ ├── extract1d.src.mlir │ │ ├── extract1d.tgt.mlir │ │ ├── extract1d_arg.src.mlir │ │ ├── extract1d_arg.tgt.mlir │ │ ├── extract2d_arg.src.mlir │ │ ├── extract2d_arg.tgt.mlir │ │ ├── extract2d_arg2.src.mlir │ │ ├── extract2d_arg2.tgt.mlir │ │ ├── extract2d_arg3.src.mlir │ │ ├── extract2d_arg3.tgt.mlir │ │ ├── extract_lowerdim.src.mlir │ │ ├── extract_lowerdim.tgt.mlir │ │ ├── extract_sizechk.src.mlir │ │ ├── extract_sizechk.tgt.mlir │ │ ├── extract_stride2.src.mlir │ │ ├── extract_stride2.tgt.mlir │ │ ├── extract_tensor_sum.src.mlir │ │ ├── extract_tensor_sum.tgt.mlir │ │ ├── extract_tensorarg.src.mlir │ │ ├── extract_tensorarg.tgt.mlir │ │ ├── extract_ub.src.mlir │ │ ├── extract_ub.tgt.mlir │ │ ├── fold_collapse_collapse.src.mlir │ │ ├── fold_collapse_collapse.tgt.mlir │ │ ├── fold_expand_collapse.src.mlir │ │ ├── fold_expand_collapse.tgt.mlir │ │ ├── from_elements.src.mlir │ │ ├── from_elements.tgt.mlir │ │ ├── from_elements2.src.mlir │ │ ├── from_elements2.tgt.mlir │ │ ├── from_elements2_bad.src.mlir │ │ ├── from_elements2_bad.tgt.mlir │ │ ├── from_elements_arg.src.mlir │ │ ├── from_elements_arg.tgt.mlir │ │ ├── generate-bad.src.mlir │ │ ├── generate-bad.tgt.mlir │ │ ├── generate-dim.src.mlir │ │ ├── generate-dim.tgt.mlir │ │ ├── generate.src.mlir │ │ ├── generate.tgt.mlir │ │ ├── insert.src.mlir │ │ ├── insert.tgt.mlir │ │ ├── insert_bad.src.mlir │ │ ├── insert_bad.tgt.mlir │ │ ├── insert_lowerdim.src.mlir │ │ ├── insert_lowerdim.tgt.mlir │ │ ├── insert_slice1.src.mlir │ │ ├── insert_slice1.tgt.mlir │ │ ├── insert_slice2.src.mlir │ │ ├── insert_slice2.tgt.mlir │ │ ├── insert_slice3.src.mlir │ │ ├── insert_slice3.tgt.mlir │ │ ├── insert_slice4.src.mlir │ │ ├── insert_slice4.tgt.mlir │ │ ├── insert_slice5.src.mlir │ │ ├── insert_slice5.tgt.mlir │ │ ├── insert_slice_stride.src.mlir │ │ ├── insert_slice_stride.tgt.mlir │ │ ├── pad.src.mlir │ │ ├── pad.tgt.mlir │ │ ├── pad2.src.mlir │ │ ├── pad2.tgt.mlir │ │ ├── pad3.src.mlir │ │ ├── pad3.tgt.mlir │ │ ├── tensor_expand_shape.src.mlir │ │ ├── tensor_expand_shape.tgt.mlir │ │ ├── use-neg-zero.src.mlir │ │ └── use-neg-zero.tgt.mlir │ ├── tosa-constant │ │ ├── dense.src.mlir │ │ ├── dense.tgt.mlir │ │ ├── dense2.src.mlir │ │ ├── dense2.tgt.mlir │ │ ├── fp.src.mlir │ │ ├── fp.tgt.mlir │ │ ├── multidim-bad.src.mlir │ │ ├── multidim-bad.tgt.mlir │ │ ├── multidim.src.mlir │ │ └── multidim.tgt.mlir │ ├── tosa-ops │ │ ├── add.src.mlir │ │ ├── add.tgt.mlir │ │ ├── add_broadcast1.src.mlir │ │ ├── add_broadcast1.tgt.mlir │ │ ├── add_broadcast2.src.mlir │ │ ├── add_broadcast2.tgt.mlir │ │ ├── add_broadcast3.src.mlir │ │ ├── add_broadcast3.tgt.mlir │ │ ├── add_broadcast4.src.mlir │ │ ├── add_broadcast4.tgt.mlir │ │ ├── add_broadcast5.src.mlir │ │ ├── add_broadcast5.tgt.mlir │ │ ├── add_broadcast_unknownsz.src.mlir │ │ ├── add_broadcast_unknownsz.tgt.mlir │ │ ├── avgpool2d.src.mlir │ │ ├── avgpool2d.tgt.mlir │ │ ├── avgpool2d_memref.src.mlir │ │ ├── avgpool2d_memref.tgt.mlir │ │ ├── bitwise_and.src.mlir │ │ ├── bitwise_and.tgt.mlir │ │ ├── bitwise_and2.src.mlir │ │ ├── bitwise_and2.tgt.mlir │ │ ├── bitwise_broadcast.src.mlir │ │ ├── bitwise_broadcast.tgt.mlir │ │ ├── bitwise_not.src.mlir │ │ ├── bitwise_not.tgt.mlir │ │ ├── bitwise_or.src.mlir │ │ ├── bitwise_or.tgt.mlir │ │ ├── bitwise_or2.src.mlir │ │ ├── bitwise_or2.tgt.mlir │ │ ├── bitwise_xor.src.mlir │ │ ├── bitwise_xor.tgt.mlir │ │ ├── bitwise_xor2.src.mlir │ │ ├── bitwise_xor2.tgt.mlir │ │ ├── concat-bad.src.mlir │ │ ├── concat-bad.tgt.mlir │ │ ├── concat.src.mlir │ │ ├── concat.tgt.mlir │ │ ├── concat2.src.mlir │ │ ├── concat2.tgt.mlir │ │ ├── conv2d1.src.mlir │ │ ├── conv2d1.tgt.mlir │ │ ├── conv2d2.src.mlir │ │ ├── conv2d2.tgt.mlir │ │ ├── conv2d3.src.mlir │ │ ├── conv2d3.tgt.mlir │ │ ├── depthwise1.src.mlir │ │ ├── depthwise1.tgt.mlir │ │ ├── depthwise2.src.mlir │ │ ├── depthwise2.tgt.mlir │ │ ├── depthwise3.src.mlir │ │ ├── depthwise3.tgt.mlir │ │ ├── depthwise4.src.mlir │ │ ├── depthwise4.tgt.mlir │ │ ├── depthwise5.src.mlir │ │ ├── depthwise5.tgt.mlir │ │ ├── exp-inf.src.mlir │ │ ├── exp-inf.tgt.mlir │ │ ├── exp-nan.src.mlir │ │ ├── exp-nan.tgt.mlir │ │ ├── exp-neginf.src.mlir │ │ ├── exp-neginf.tgt.mlir │ │ ├── exp-zero.src.mlir │ │ ├── exp-zero.tgt.mlir │ │ ├── gather-const-bad.src.mlir │ │ ├── gather-const-bad.tgt.mlir │ │ ├── gather-const.src.mlir │ │ ├── gather-const.tgt.mlir │ │ ├── gather-oob.src.mlir │ │ ├── gather-oob.tgt.mlir │ │ ├── gather-uninit-index.src.mlir │ │ ├── gather-uninit-index.tgt.mlir │ │ ├── gather-uninit.src.mlir │ │ ├── gather-uninit.tgt.mlir │ │ ├── gather.src.mlir │ │ ├── gather.tgt.mlir │ │ ├── gather_unknown_size.src.mlir │ │ ├── gather_unknown_size.tgt.mlir │ │ ├── maxpool2d.src.mlir │ │ ├── maxpool2d.tgt.mlir │ │ ├── maxpool2d_memref.src.mlir │ │ ├── maxpool2d_memref.tgt.mlir │ │ ├── maxpool_noop.src.mlir │ │ ├── maxpool_noop.tgt.mlir │ │ ├── mul_comm.src.mlir │ │ ├── mul_comm.tgt.mlir │ │ ├── mul_shift.src.mlir │ │ ├── mul_shift.tgt.mlir │ │ ├── negate.src.mlir │ │ ├── negate.tgt.mlir │ │ ├── negate_int.src.mlir │ │ ├── negate_int.tgt.mlir │ │ ├── reduce_sum-bad.src.mlir │ │ ├── reduce_sum-bad.tgt.mlir │ │ ├── reduce_sum_int-bad.src.mlir │ │ ├── reduce_sum_int-bad.tgt.mlir │ │ ├── reshape.src.mlir │ │ ├── reshape.tgt.mlir │ │ ├── reverse-fold.src.mlir │ │ ├── reverse-fold.tgt.mlir │ │ ├── reverse.src.mlir │ │ ├── reverse.tgt.mlir │ │ ├── sub.src.mlir │ │ ├── sub.tgt.mlir │ │ ├── tile-bad.src.mlir │ │ ├── tile-bad.tgt.mlir │ │ ├── tile.src.mlir │ │ ├── tile.tgt.mlir │ │ ├── transpose1.src.mlir │ │ ├── transpose1.tgt.mlir │ │ ├── transpose2.src.mlir │ │ ├── transpose2.tgt.mlir │ │ ├── transpose3.src.mlir │ │ └── transpose3.tgt.mlir │ └── verbose │ │ ├── conv2d1.src.mlir │ │ ├── conv2d1.tgt.mlir │ │ ├── fpbits.src.mlir │ │ ├── fpbits.tgt.mlir │ │ ├── fpcount.src.mlir │ │ ├── fpcount.tgt.mlir │ │ ├── memrefcount.src.mlir │ │ └── memrefcount.tgt.mlir ├── long-opts │ ├── conv2d-to-img2col │ │ ├── nhwc_filter-bad.src.mlir │ │ └── nhwc_filter-bad.tgt.mlir │ ├── conv2d │ │ ├── conv2d2.src.mlir │ │ ├── conv2d2.tgt.mlir │ │ ├── convolution_nchw.src.mlir │ │ └── convolution_nchw.tgt.mlir │ ├── fold-tensor-extract-op │ │ ├── var.src.mlir │ │ └── var.tgt.mlir │ ├── llvmcpu-plan-conv-loop-order │ │ ├── simple-bad.src.mlir │ │ ├── simple-bad.tgt.mlir │ │ ├── simple-small.src.mlir │ │ ├── simple-small.tgt.mlir │ │ ├── simple.src.mlir │ │ └── simple.tgt.mlir │ └── tosa-to-linalg │ │ ├── conv2d2.src.mlir │ │ ├── conv2d2.tgt.mlir │ │ ├── conv_pad.src.mlir │ │ ├── conv_pad.tgt.mlir │ │ ├── depthwise2.src.mlir │ │ └── depthwise2.tgt.mlir ├── opts │ ├── conv2d-to-img2col │ │ ├── nhwc_filter.src.mlir │ │ └── nhwc_filter.tgt.mlir │ ├── convert-elementwise-to-linalg │ │ ├── add.src.mlir │ │ ├── add.tgt.mlir │ │ ├── add2.src.mlir │ │ └── add2.tgt.mlir │ ├── fold-memref-subview-op │ │ ├── const_tensor.src.mlir │ │ ├── const_tensor.tgt.mlir │ │ ├── rank_reduction.src.mlir │ │ ├── rank_reduction.tgt.mlir │ │ ├── var_tensor-bad.src.mlir │ │ ├── var_tensor-bad.tgt.mlir │ │ ├── var_tensor.src.mlir │ │ └── var_tensor.tgt.mlir │ ├── fold-tensor-extract-op │ │ ├── const-bad.src.mlir │ │ ├── const-bad.tgt.mlir │ │ ├── const.src.mlir │ │ ├── const.tgt.mlir │ │ ├── twoargs.src.mlir │ │ └── twoargs.tgt.mlir │ ├── fusion-tensor │ │ ├── const-bad.src.mlir │ │ ├── const-bad.tgt.mlir │ │ ├── const.src.mlir │ │ ├── const.tgt.mlir │ │ ├── i32-bad.src.mlir │ │ ├── i32-bad.tgt.mlir │ │ ├── i32.src.mlir │ │ ├── i32.tgt.mlir │ │ ├── nontensor-bad.src.mlir │ │ ├── nontensor-bad.tgt.mlir │ │ ├── nontensor.src.mlir │ │ ├── nontensor.tgt.mlir │ │ ├── simple-bad.src.mlir │ │ ├── simple-bad.tgt.mlir │ │ ├── simple.src.mlir │ │ ├── simple.tgt.mlir │ │ ├── sum.src.mlir │ │ ├── sum.tgt.mlir │ │ ├── sum_comm.src.mlir │ │ ├── sum_comm.tgt.mlir │ │ ├── tensor_extract.src.mlir │ │ ├── tensor_extract.tgt.mlir │ │ ├── transpose-bad.src.mlir │ │ ├── transpose-bad.tgt.mlir │ │ ├── transpose.src.mlir │ │ ├── transpose.tgt.mlir │ │ ├── zerodim.src.mlir │ │ └── zerodim.tgt.mlir │ ├── linalg-bufferize │ │ ├── depthwise1.src.mlir │ │ ├── depthwise1.tgt.mlir │ │ ├── depthwise2.src.mlir │ │ ├── depthwise2.tgt.mlir │ │ ├── fill-bad.src.mlir │ │ ├── fill-bad.tgt.mlir │ │ ├── fill.src.mlir │ │ └── fill.tgt.mlir │ ├── linalg-canonicalize │ │ ├── from_elem1.src.mlir │ │ ├── from_elem1.tgt.mlir │ │ ├── from_elem2.src.mlir │ │ ├── from_elem2.tgt.mlir │ │ ├── id.src.mlir │ │ └── id.tgt.mlir │ ├── linalg-fold-unit-extent-dims │ │ ├── drop-unit-extent-dims.src.mlir │ │ ├── drop-unit-extent-dims.tgt.mlir │ │ ├── one-trip-loop.src.mlir │ │ └── one-trip-loop.tgt.mlir │ ├── linalg-generalize-named-ops │ │ ├── copy.src.mlir │ │ ├── copy.tgt.mlir │ │ ├── fill.src.mlir │ │ ├── fill.tgt.mlir │ │ ├── matmul.src.mlir │ │ └── matmul.tgt.mlir │ ├── tensor-constant-bufferize │ │ ├── dense.src.mlir │ │ ├── dense.tgt.mlir │ │ ├── sparse.src.mlir │ │ ├── sparse.tgt.mlir │ │ ├── sparse_int.src.mlir │ │ └── sparse_int.tgt.mlir │ ├── tosa-make-broadcastable │ │ ├── broadcast1.src.mlir │ │ └── broadcast1.tgt.mlir │ └── tosa-to-linalg │ │ ├── abs.src.mlir │ │ ├── abs.tgt.mlir │ │ ├── add.src.mlir │ │ ├── add.tgt.mlir │ │ ├── clamp.src.mlir │ │ ├── clamp.tgt.mlir │ │ ├── concat.src.mlir │ │ ├── concat.tgt.mlir │ │ ├── conv2d1.src.mlir │ │ ├── conv2d1.tgt.mlir │ │ ├── depthwise1.src.mlir │ │ ├── depthwise1.tgt.mlir │ │ ├── depthwise3.src.mlir │ │ ├── depthwise3.tgt.mlir │ │ ├── fully_connected.src.mlir │ │ ├── fully_connected.tgt.mlir │ │ ├── gather.src.mlir │ │ ├── gather.tgt.mlir │ │ ├── mul.src.mlir │ │ ├── mul.tgt.mlir │ │ ├── muli.src.mlir │ │ ├── muli.tgt.mlir │ │ ├── reciprocal.src.mlir │ │ ├── reciprocal.tgt.mlir │ │ ├── reduce_sum.src.mlir │ │ ├── reduce_sum.tgt.mlir │ │ ├── reduce_sum2.src.mlir │ │ ├── reduce_sum2.tgt.mlir │ │ ├── reduce_sum3.src.mlir │ │ ├── reduce_sum3.tgt.mlir │ │ ├── reverse.src.mlir │ │ ├── reverse.tgt.mlir │ │ ├── tile.src.mlir │ │ └── tile.tgt.mlir └── passes.py └── unittests ├── CMakeLists.txt ├── README.md ├── state_test.cpp ├── tv_test_shared.h └── value_test.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | build 3 | venv 4 | **/__pycache__ 5 | .DS_Store 6 | .cache 7 | tests/Testing 8 | -------------------------------------------------------------------------------- /src/debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "llvm/Support/raw_ostream.h" 4 | #include 5 | 6 | void setVerbose(bool vb); 7 | 8 | llvm::raw_ostream &verbose(const std::string &prefix); -------------------------------------------------------------------------------- /src/encode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "state.h" 4 | #include "mlir/Dialect/Func/IR/FuncOps.h" 5 | #include "mlir/Dialect/Linalg/IR/Linalg.h" 6 | 7 | #include 8 | #include 9 | 10 | // encode can throw UnsupportedException. 11 | void encode(State &st, mlir::func::FuncOp &fn, bool printOps); 12 | -------------------------------------------------------------------------------- /src/opts.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "llvm/Support/CommandLine.h" 4 | 5 | extern llvm::cl::OptionCategory MlirTvCategory; -------------------------------------------------------------------------------- /src/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | #include "llvm/Support/raw_ostream.h" 3 | 4 | using namespace std; 5 | 6 | string to_string(mlir::Type t) { 7 | string ss; 8 | llvm::raw_string_ostream os(ss); 9 | os << t; 10 | os.flush(); 11 | return ss; 12 | } 13 | -------------------------------------------------------------------------------- /tests/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | config.my_src_root = r"@CMAKE_SOURCE_DIR@" 4 | config.my_obj_root= r"@CMAKE_BINARY_DIR@" 5 | lit_config.load_config(config, os.path.join(config.my_src_root, "tests/lit.cfg.py")) 6 | -------------------------------------------------------------------------------- /tests/lit/__init__.py: -------------------------------------------------------------------------------- 1 | """'lit' Testing Tool""" 2 | 3 | __author__ = 'Daniel Dunbar' 4 | __email__ = 'daniel@minormatter.com' 5 | __versioninfo__ = (12, 0, 0) 6 | __version__ = '.'.join(str(v) for v in __versioninfo__) 7 | 8 | __all__ = [] 9 | -------------------------------------------------------------------------------- /tests/lit/builtin_commands/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aqjune/mlir-tv/897c87004dcc1397685b3781e71025a6f4dfe40a/tests/lit/builtin_commands/__init__.py -------------------------------------------------------------------------------- /tests/lit/formats/__init__.py: -------------------------------------------------------------------------------- 1 | from lit.formats.base import ( # noqa: F401 2 | TestFormat, 3 | FileBasedTest, 4 | OneCommandPerFileTest, 5 | ExecutableTest 6 | ) 7 | 8 | from lit.formats.googletest import GoogleTest # noqa: F401 9 | from lit.formats.shtest import ShTest # noqa: F401 10 | from lit.formats.mlirtest import SrcTgtPairTest # added by mlir-tv 11 | -------------------------------------------------------------------------------- /tests/lit/llvm/__init__.py: -------------------------------------------------------------------------------- 1 | from lit.llvm import config 2 | 3 | llvm_config = None 4 | 5 | 6 | def initialize(lit_config, test_config): 7 | global llvm_config 8 | 9 | llvm_config = config.LLVMConfig(lit_config, test_config) 10 | -------------------------------------------------------------------------------- /tests/litmus/abstraction/dot.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "dot ops (fp): SUM_MUL" 2 | 3 | func.func @f(%a: tensor, %b: tensor) -> tensor { 4 | %zero = arith.constant -0.0 : f32 5 | %i = tensor.empty (): tensor 6 | %outty = linalg.fill ins(%zero: f32) outs(%i: tensor) -> tensor 7 | %e = linalg.dot ins(%a, %b : tensor,tensor) 8 | outs(%outty: tensor) -> tensor 9 | return %e : tensor 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/abstraction/dotint.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "dot ops (int): SUM_MUL" 2 | 3 | func.func @f(%a: tensor, %b: tensor) -> tensor { 4 | %zero = arith.constant 0 : i32 5 | %i = tensor.empty (): tensor 6 | %outty = linalg.fill ins(%zero: i32) outs(%i: tensor) -> tensor 7 | %e = linalg.dot ins(%a, %b : tensor,tensor) 8 | outs(%outty: tensor) -> tensor 9 | return %e : tensor 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/affine-ops/add.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: index) -> index { 4 | %res = affine.apply affine_map<(i) -> (i+1+2)> (%x) 5 | return %res: index 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/affine-ops/add.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x: index) -> index { 2 | %res = affine.apply affine_map<(i) -> (i+3)> (%x) 3 | return %res: index 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/affine-ops/mul.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: index) -> index { 4 | %res = affine.apply affine_map<(i) -> (i*2)> (%x) 5 | return %res: index 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/affine-ops/mul.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x: index) -> index { 2 | %res = affine.apply affine_map<(i) -> (i+i)> (%x) 3 | return %res: index 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/addi.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%v: i32, %w: i32) -> i32 { 4 | %x = arith.addi %v, %w: i32 5 | return %x: i32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/addi.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%v: i32, %w: i32) -> i32 { 4 | %x = arith.addi %w, %v: i32 5 | return %x: i32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/addi_tensor.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%v: tensor<2xi32>, %w: tensor<2xi32>) -> tensor<2xi32> { 4 | %x = arith.addi %v, %w: tensor<2xi32> 5 | return %x: tensor<2xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/addi_tensor.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%v: tensor<2xi32>, %w: tensor<2xi32>) -> tensor<2xi32> { 4 | %x = arith.addi %w, %v: tensor<2xi32> 5 | return %x: tensor<2xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/cmpi_index.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> i1 { 4 | %c1 = arith.constant 1 : index 5 | %c13 = arith.constant 13 : index 6 | %0 = arith.cmpi slt, %c13, %c1 : index 7 | return %0 : i1 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/cmpi_index.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> i1 { 4 | %i = arith.constant 0 : i1 5 | return %i: i1 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/index_cast.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | // Running –convert-std-to-llvm shows that index_cast is sext 4 | 5 | func.func @index_cast() -> index { 6 | %c = arith.constant -1: i32 7 | %y = arith.index_cast %c : i32 to index 8 | return %y: index 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/index_cast.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @index_cast() -> index { 2 | %c = arith.constant -1: index 3 | return %c: index 4 | } 5 | 6 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/index_cast_tensor.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @index_cast(%tensor: tensor) -> tensor { 4 | %index_tensor = arith.index_cast %tensor : tensor to tensor 5 | %res = arith.index_cast %index_tensor: tensor to tensor 6 | return %res : tensor 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/index_cast_tensor.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @index_cast(%tensor: tensor) -> tensor { 2 | return %tensor : tensor 3 | } 4 | 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/muli.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> i32 { 4 | %v = arith.constant 3: i32 5 | %w = arith.constant 2: i32 6 | %x = arith.muli %v, %w: i32 7 | return %x: i32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/muli.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> i32 { 2 | %x = arith.constant 6: i32 3 | return %x: i32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/negf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xf32> { 4 | %c0 = "tosa.const"() {value = dense<[1.0, 2.0, 3.0, 4.0]> : tensor<4xf32>} : () -> tensor<4xf32> 5 | %a = "arith.negf"(%c0) : (tensor<4xf32>) -> tensor<4xf32> 6 | return %a: tensor<4xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/negf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xf32> { 2 | %c0 = "tosa.const"() {value = dense<[-1.0, -2.0, -3.0, -4.0]> : tensor<4xf32>} : () -> tensor<4xf32> 3 | return %c0: tensor<4xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shli_index_ub.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @shift_left_index_ub(%v: index) -> index { 4 | %amnt = arith.constant 32: index 5 | %x = arith.shli %v, %amnt: index 6 | return %x: index 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shli_index_ub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @shift_left_index_ub(%v: index) -> index { 2 | %x = arith.constant 0xf0f0f0f0: index 3 | return %x: index 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shli_tensor_ub.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @shift_left_tensor_ub(%t: tensor<5xi32>) -> tensor<5xi32> { 4 | %amnt = arith.constant dense<32> : tensor<5xi32> 5 | %x = arith.shli %t, %amnt: tensor<5xi32> 6 | return %x: tensor<5xi32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shli_tensor_ub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @shift_left_tensor_ub(%t: tensor<5xi32>) -> tensor<5xi32> { 2 | %amnt = arith.constant dense<0xf0f0f0f0> : tensor<5xi32> 3 | %x = arith.shli %t, %amnt: tensor<5xi32> 4 | return %x: tensor<5xi32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shli_ub.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @shift_left_ub(%v: i32) -> i32 { 4 | %amnt = arith.constant 32: i32 5 | %x = arith.shli %v, %amnt: i32 6 | return %x: i32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shli_ub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @shift_left_ub(%v: i32) -> i32 { 2 | %x = arith.constant 0xf0f0f0f0: i32 3 | return %x: i32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shrsi_ub.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @shift_right_signed_ub(%v: i32) -> i32 { 4 | %amnt = arith.constant 32: i32 5 | %x = arith.shrsi %v, %amnt: i32 6 | return %x: i32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shrsi_ub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @shift_right_signed_ub(%v: i32) -> i32 { 2 | %x = arith.constant 0xf0f0f0f0: i32 3 | return %x: i32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shrui_ub.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @shift_right_unsigned_ub(%v: i32) -> i32 { 4 | %amnt = arith.constant 32: i32 5 | %x = arith.shrui %v, %amnt: i32 6 | return %x: i32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/shrui_ub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @shift_right_unsigned_ub(%v: i32) -> i32 { 2 | %x = arith.constant 0xf0f0f0f0: i32 3 | return %x: i32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/subf-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%v: f32, %w: f32) -> f32 { 4 | %x = arith.subf %v, %w: f32 5 | return %x: f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/subf-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%v: f32, %w: f32) -> f32 { 2 | %x = arith.negf %v: f32 3 | %y = arith.addf %w, %x: f32 4 | return %y: f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/subf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%v: f32, %w: f32) -> f32 { 4 | %x = arith.subf %v, %w: f32 5 | return %x: f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/subf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%v: f32, %w: f32) -> f32 { 2 | %x = arith.negf %w: f32 3 | %y = arith.addf %v, %x: f32 4 | return %y: f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/trunci.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @i32_to_i16() -> i16 { 2 | %c = arith.constant 0x1234: i16 3 | return %c: i16 4 | } 5 | 6 | func.func @i64_to_i32() -> i32 { 7 | %c = arith.constant 0x10001000: i32 8 | return %c: i32 9 | } 10 | 11 | func.func @i64_to_i16() -> i16 { 12 | %c = arith.constant 0: i16 13 | return %c: i16 14 | } 15 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/xori.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> i32 { 4 | %v = arith.constant 3: i32 5 | %w = arith.constant -1: i32 6 | %x = arith.xori %v, %w: i32 7 | return %x: i32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/arith-ops/xori.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> i32 { 2 | %x = arith.constant -4: i32 3 | return %x: i32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/buffer_cast.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @buffer_cast(%arg : tensor<2x3xf32>) -> f32 4 | { 5 | %c0 = arith.constant 0 : index 6 | %c1 = arith.constant 1 : index 7 | %0 = bufferization.to_memref %arg : memref<2x3xf32> 8 | %1 = memref.load %0[%c0, %c1] : memref<2x3xf32> 9 | return %1 : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/buffer_cast.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @buffer_cast(%arg : tensor<2x3xf32>) -> f32 2 | { 3 | %c0 = arith.constant 0 : index 4 | %c1 = arith.constant 1 : index 5 | %0 = tensor.extract %arg[%c0, %c1] : tensor<2x3xf32> 6 | return %0 : f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/buffer_cast_i8.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @buffer_cast(%arg : tensor<2x3xi8>) -> i8 4 | { 5 | %c0 = arith.constant 0 : index 6 | %c1 = arith.constant 1 : index 7 | %0 = bufferization.to_memref %arg : memref<2x3xi8> 8 | %1 = memref.load %0[%c0, %c1] : memref<2x3xi8> 9 | return %1 : i8 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/buffer_cast_i8.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @buffer_cast(%arg : tensor<2x3xi8>) -> i8 2 | { 3 | %c0 = arith.constant 0 : index 4 | %c1 = arith.constant 1 : index 5 | %0 = tensor.extract %arg[%c0, %c1] : tensor<2x3xi8> 6 | return %0 : i8 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/buffer_cast_zero.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @buffer_cast(%arg : tensor<0xf32>) -> () 4 | { 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/buffer_cast_zero.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @buffer_cast(%arg : tensor<0xf32>) -> () 2 | { 3 | // This must not be UB. 4 | %0 = bufferization.to_memref %arg : memref<0xf32> 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/bufferize-select.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @select(%arg0: i1, %arg1: tensor, %arg2: tensor) -> tensor { 4 | %0 = arith.select %arg0, %arg1, %arg2 : tensor 5 | return %0 : tensor 6 | } 7 | 8 | // How to reproduce tgt: 9 | // mlir-opt -std-bufferize -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/bufferize-select.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @select(%arg0: i1, %arg1: tensor, %arg2: tensor) -> tensor { 3 | %0 = bufferization.to_memref %arg1 : memref 4 | %1 = bufferization.to_memref %arg2 : memref 5 | %2 = arith.select %arg0, %0, %1 : memref 6 | %3 = bufferization.to_tensor %2 : memref 7 | return %3 : tensor 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/bufferize-select2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @select(%arg0: i1, %arg1: tensor, %arg2: tensor) -> tensor { 4 | %0 = arith.select %arg0, %arg1, %arg2 : tensor 5 | return %0 : tensor 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/bufferize-select2.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @select(%arg0: i1, %arg1: tensor, %arg2: tensor) -> tensor { 3 | %0 = bufferization.to_memref %arg1 : memref 4 | %1 = bufferization.to_memref %arg2 : memref 5 | %2 = arith.select %arg0, %0, %1 : memref 6 | %3 = bufferization.to_tensor %2 : memref 7 | return %3 : tensor 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/clone-no-introduce.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%arg : memref<2x3xf32>) 4 | { 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/clone-no-introduce.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg : memref<2x3xf32>) 2 | { 3 | // This makes the block unwritable. 4 | bufferization.clone %arg: memref<2x3xf32> to memref<2x3xf32> 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/clone-removal.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg : memref<2x3xf32>) 4 | { 5 | bufferization.clone %arg: memref<2x3xf32> to memref<2x3xf32> 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/clone-removal.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg : memref<2x3xf32>) 2 | { 3 | return 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/clone.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg : memref<2x3xf32>) -> tensor<2x3xf32> 4 | { 5 | %0 = bufferization.to_tensor %arg : memref<2x3xf32> 6 | %v = bufferization.clone %arg: memref<2x3xf32> to memref<2x3xf32> // Cannot remove this since it makes the block unwritable 7 | return %0: tensor<2x3xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/clone.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg : memref<2x3xf32>) -> tensor<2x3xf32> 2 | { 3 | %v = bufferization.clone %arg: memref<2x3xf32> to memref<2x3xf32> 4 | %0 = bufferization.to_tensor %v : memref<2x3xf32> 5 | return %0: tensor<2x3xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/copy.src.mlir: -------------------------------------------------------------------------------- 1 | // ARGS: -smt-to=60000 2 | // VERIFY 3 | 4 | func.func @copy(%m1: memref<10x10xf32>, %m2: memref<10x10xf32>) -> (tensor<10x10xf32>, tensor<10x10xf32>) 5 | { 6 | memref.copy %m1, %m2 : memref<10x10xf32> to memref<10x10xf32> 7 | %t1 = bufferization.to_tensor %m1 : memref<10x10xf32> 8 | %t2 = bufferization.to_tensor %m2 : memref<10x10xf32> 9 | return %t1, %t2 : tensor<10x10xf32>, tensor<10x10xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/copy.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @copy(%m1: memref<10x10xf32>, %m2: memref<10x10xf32>) -> (tensor<10x10xf32>, tensor<10x10xf32>) 2 | { 3 | memref.copy %m1, %m2 : memref<10x10xf32> to memref<10x10xf32> 4 | %t1 = bufferization.to_tensor %m1 : memref<10x10xf32> 5 | %t2 = bufferization.to_tensor %m2 : memref<10x10xf32> 6 | return %t2, %t1 : tensor<10x10xf32>, tensor<10x10xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/copy_i32.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @copy(%m1: memref<10x10xi32>, %m2: memref<10x10xi32>) -> (tensor<10x10xi32>, tensor<10x10xi32>) 2 | { 3 | memref.copy %m1, %m2 : memref<10x10xi32> to memref<10x10xi32> 4 | %t1 = bufferization.to_tensor %m1 : memref<10x10xi32> 5 | %t2 = bufferization.to_tensor %m2 : memref<10x10xi32> 6 | return %t2, %t1 : tensor<10x10xi32>, tensor<10x10xi32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/fill-memref-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @bufferize_fill(%arg0: memref) -> tensor { 4 | %cst = arith.constant 0.000000e+00 : f32 5 | linalg.fill ins(%cst: f32) outs(%arg0: memref) 6 | %zerotensor = bufferization.to_tensor %arg0 : memref 7 | return %zerotensor : tensor 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/fill-memref.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @bufferize_fill(%arg0: memref) -> tensor { 4 | %cst = arith.constant 0.000000e+00 : f32 5 | linalg.fill ins(%cst: f32) outs(%arg0: memref) 6 | %zerotensor = bufferization.to_tensor %arg0 : memref 7 | return %zerotensor : tensor 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/tensor_load.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @tensor_load(%arg : memref<2x3xf32>) -> f32 4 | { 5 | %c0 = arith.constant 0 : index 6 | %c1 = arith.constant 1 : index 7 | %0 = bufferization.to_tensor %arg : memref<2x3xf32> 8 | %1 = tensor.extract %0[%c0, %c1] : tensor<2x3xf32> 9 | memref.store %1, %arg[%c0, %c1] : memref<2x3xf32> 10 | return %1 : f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/tensor_load.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @tensor_load(%arg : memref<2x3xf32>) -> f32 2 | { 3 | %c0 = arith.constant 0 : index 4 | %c1 = arith.constant 1 : index 5 | %0 = bufferization.to_tensor %arg : memref<2x3xf32> 6 | %1 = tensor.extract %0[%c0, %c1] : tensor<2x3xf32> 7 | memref.store %1, %arg[%c0, %c1] : memref<2x3xf32> 8 | return %1 : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/var_buffer_cast.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @var_buffer_cast(%arg : tensor) -> f32 4 | { 5 | %c0 = arith.constant 0 : index 6 | %c1 = arith.constant 1 : index 7 | %0 = bufferization.to_memref %arg : memref 8 | %1 = memref.load %0[%c0, %c1] : memref 9 | return %1 : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/bufferization-ops/var_buffer_cast.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @var_buffer_cast(%arg : tensor) -> f32 2 | { 3 | %c0 = arith.constant 0 : index 4 | %c1 = arith.constant 1 : index 5 | %0 = tensor.extract %arg[%c0, %c1] : tensor 6 | return %0 : f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/cexprint/fp.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Tgt: 2" 2 | 3 | func.func @f() -> (f32, f32) { 4 | %c0 = arith.constant 0.0: f32 5 | %c1 = arith.constant 1.0: f32 6 | return %c0, %c1: f32, f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/cexprint/fp.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> (f32, f32) { 2 | %c0 = arith.constant 0.0: f32 3 | %c2 = arith.constant 2.0: f32 4 | return %c0, %c2: f32, f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/cexprint/reverse.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Value: (dim: 2, 2) (0, 0) -> 3, (0, 1) -> 4, (1, 0) -> 1, (1, 1) -> 2" 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %rt = "tosa.reverse"(%t) {axis = 0 : i32} : (tensor<2x2xi32>) -> tensor<2x2xi32> 6 | return %rt: tensor<2x2xi32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/cexprint/reverse.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %rt = "tosa.const"() {value = dense<[[3, 4], [1, 3]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %rt: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/diagnostics/memref-missing-bugs.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "mlir-tv assumes that memrefs of different element types do not alias. This can cause missing bugs." 2 | 3 | func.func @f(%a: memref, %b: memref) { 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/diagnostics/memref-missing-bugs.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: memref, %b: memref) { 2 | return 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/diagnostics/store-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "liveness (src): true" 2 | 3 | // Check that liveness is printed in the counter example 4 | 5 | func.func @f(%a: memref<1xf32>) { 6 | %c0 = arith.constant 0: index 7 | %v = arith.constant 1.1: f32 8 | memref.store %v, %a[%c0]: memref<1xf32> 9 | return 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/diagnostics/store-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: memref<1xf32>) { 2 | %c0 = arith.constant 0: index 3 | %v2 = arith.constant 1.2: f32 4 | memref.store %v2, %a[%c0]: memref<1xf32> 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/add_assoc.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --associative 3 | 4 | func.func @f() -> f32 { 5 | %a0 = arith.constant -12.0 : f32 6 | %a1 = arith.constant 2.0 : f32 7 | %a2 = arith.constant 3.0 : f32 8 | %a3 = arith.constant 0.0 : f32 9 | %c0 = arith.addf %a0, %a1 : f32 10 | %c1 = arith.addf %a2, %a3 : f32 11 | %sum = arith.addf %c0, %c1: f32 12 | return %sum: f32 13 | } 14 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/add_assoc.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a0 = arith.constant -12.0 : f32 3 | %a1 = arith.constant 2.0 : f32 4 | %a2 = arith.constant 3.0 : f32 5 | %a3 = arith.constant 0.0 : f32 6 | %c0 = arith.addf %a0, %a1 : f32 7 | %c1 = arith.addf %c0, %a2 : f32 8 | %sum = arith.addf %c1, %a3 : f32 9 | return %sum: f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/cmp_const-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @olt(%arg0: f32) -> i1 { 4 | %i = arith.constant 3.0 : f32 5 | %c = arith.cmpf "olt", %i, %arg0 : f32 6 | return %c : i1 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/cmp_const-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @olt(%arg0: f32) -> i1 { 2 | %i = arith.constant 2.0 : f32 3 | %c = arith.cmpf "olt", %i, %arg0 : f32 4 | return %c : i1 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/cmp_fixed.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @true(%arg0: f32, %arg1: f32) -> i1 { 4 | %c = arith.cmpf "true", %arg0, %arg1 : f32 5 | return %c : i1 6 | } 7 | 8 | func.func @false(%arg0: f32, %arg1: f32) -> i1 { 9 | %c = arith.cmpf "false", %arg0, %arg1 : f32 10 | return %c : i1 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/cmp_fixed.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @true(%arg0: f32, %arg1: f32) -> i1 { 2 | %c = arith.constant 1 : i1 3 | return %c : i1 4 | } 5 | 6 | func.func @false(%arg0: f32, %arg1: f32) -> i1 { 7 | %c = arith.constant 0 : i1 8 | return %c : i1 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/cmp_ord-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @oeq(%arg0: f32, %arg1: f32) -> i1 { 4 | %c = arith.cmpf "oeq", %arg0, %arg1 : f32 5 | return %c : i1 6 | } -------------------------------------------------------------------------------- /tests/litmus/fp-ops/cmp_ord-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @oeq(%arg0: f32, %arg1: f32) -> i1 { 2 | %c = arith.cmpf "ueq", %arg0, %arg1 : f32 3 | return %c : i1 4 | } -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_add.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 4 | %c = arith.addf %arg0, %arg1 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_add.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %c = arith.addf %arg1, %arg0 : f32 3 | return %c: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_add_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %i = arith.constant -2.0 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.addf %i, %v : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_add_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %i = arith.constant -2.0 : f32 3 | %v = arith.constant 3.0 : f32 4 | %c = arith.addf %v, %i : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_add_double.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 4 | %c = arith.addf %arg0, %arg1 : f64 5 | return %c : f64 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_add_double.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 2 | %c = arith.addf %arg1, %arg0 : f64 3 | return %c: f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_div-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 4 | %c = arith.divf %arg0, %arg1 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_div-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %c = arith.divf %arg1, %arg0 : f32 3 | return %c: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_div_const-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f32 { 4 | %i = arith.constant 2.0 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.divf %i, %v : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_div_const-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %i = arith.constant 2.0 : f32 3 | %v = arith.constant 3.0 : f32 4 | %c = arith.divf %v, %i : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_mul.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 4 | %c = arith.mulf %arg0, %arg1 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_mul.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %c = arith.mulf %arg1, %arg0 : f32 3 | return %c: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_mul_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %i = arith.constant -2.0 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.mulf %i, %v : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/comm_mul_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %i = arith.constant -2.0 : f32 3 | %v = arith.constant 3.0 : f32 4 | %c = arith.mulf %v, %i : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // This is incorrect if arg0 is NaN or Inf 4 | 5 | func.func @f(%arg0: f32) -> f64 { 6 | %e = arith.extf %arg0: f32 to f64 7 | %n = arith.negf %arg0 : f32 8 | %ne = arith.extf %n: f32 to f64 9 | %s = arith.addf %e, %ne : f64 10 | return %s: f64 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32) -> f64 { 2 | %a = arith.constant 0.0 : f64 3 | return %a: f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %a = arith.constant 0.0 : f64 3 | return %a: f64 4 | } 5 | 6 | func.func @tensor() -> tensor<5xf64> { 7 | %x = arith.constant dense<5.0> : tensor<5xf64> 8 | return %x: tensor<5xf64> 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_const_single_ext-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f64 { 4 | %a = arith.constant 3.0 : f32 5 | %e = arith.extf %a: f32 to f64 6 | %ne = arith.constant -5.0 : f64 7 | %s = arith.addf %e, %ne : f64 8 | return %s: f64 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_const_single_ext-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %a = arith.constant 0.0 : f64 3 | return %a: f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_const_single_ext.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f64 { 4 | %a = arith.constant 3.0 : f32 5 | %e = arith.extf %a: f32 to f64 6 | %ne = arith.constant -3.0 : f64 7 | %s = arith.addf %e, %ne : f64 8 | return %s: f64 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_const_single_ext.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %a = arith.constant 0.0 : f64 3 | return %a: f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_inf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f64 { 4 | %inf = arith.constant 0x7F800000 : f32 5 | %einf = arith.extf %inf: f32 to f64 6 | return %einf: f64 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_inf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %a = arith.constant 0x7FF0000000000000 : f64 3 | return %a: f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_nan.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f64 { 4 | %inf = arith.constant 0x7FC00000 : f32 5 | %einf = arith.extf %inf: f32 to f64 6 | return %einf: f64 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ext_nan.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %a = arith.constant 0x7FF7FFFFFFFFFFFF : f64 3 | return %a: f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_add.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 4 | %i = arith.constant -0.0 : f32 5 | %v1 = arith.addf %i, %arg0 : f32 6 | %v2 = arith.addf %i, %arg1 : f32 7 | %c = arith.addf %v1, %v2 : f32 8 | return %c : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_add.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %c = arith.addf %arg0, %arg1 : f32 3 | return %c: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_add_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %i = arith.constant -0.0 : f32 5 | %v = arith.constant 3.0 : f32 6 | %v1 = arith.addf %i, %v : f32 7 | %v2 = arith.addf %v, %i : f32 8 | %c = arith.addf %v1, %v2 : f32 9 | return %c : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_add_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %v1 = arith.constant 3.0 : f32 3 | %v2 = arith.constant 3.0 : f32 4 | %c = arith.addf %v1, %v2 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_add_double.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 4 | %i = arith.constant -0.0 : f64 5 | %v1 = arith.addf %i, %arg0 : f64 6 | %v2 = arith.addf %i, %arg1 : f64 7 | %c = arith.addf %v1, %v2 : f64 8 | return %c : f64 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_add_double.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 2 | %c = arith.addf %arg0, %arg1 : f64 3 | return %c: f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_div.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 4 | %i = arith.constant 1.0 : f32 5 | %v1 = arith.divf %arg0, %i : f32 6 | %v2 = arith.divf %arg1, %i : f32 7 | %c = arith.addf %v1, %v2 : f32 8 | return %c : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_div.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %c = arith.addf %arg0, %arg1 : f32 3 | return %c: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_div_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %v = arith.constant 3.0 : f32 5 | %i = arith.constant -1.0 : f32 6 | %c = arith.divf %v, %i : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_div_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant -3.0 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_mul.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 4 | %i = arith.constant 1.0 : f32 5 | %v1 = arith.mulf %i, %arg0 : f32 6 | %v2 = arith.mulf %i, %arg1 : f32 7 | %c = arith.addf %v1, %v2 : f32 8 | return %c : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_mul.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %c = arith.addf %arg0, %arg1 : f32 3 | return %c: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_mul_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %i = arith.constant 1.0 : f32 5 | %v = arith.constant 3.0 : f32 6 | %v1 = arith.mulf %i, %v : f32 7 | %v2 = arith.mulf %v, %i : f32 8 | %c = arith.mulf %v1, %v2 : f32 9 | return %c : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/ident_mul_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %v1 = arith.constant 3.0 : f32 3 | %v2 = arith.constant 3.0 : f32 4 | %c = arith.mulf %v1, %v2 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // This is incorrect if at least one of arg0 and arg1 is NaN or -Inf 4 | 5 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 6 | %inf = arith.constant 0x7F800000 : f32 7 | %v1 = arith.addf %inf, %arg0 : f32 8 | %v2 = arith.addf %inf, %arg1 : f32 9 | %c = arith.addf %v1, %v2 : f32 10 | return %c : f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %inf = arith.constant 0x7F800000 : f32 3 | %c = arith.addf %inf, %inf : f32 4 | return %c: f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_conflict.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf_p = arith.constant 0x7F800000 : f32 5 | %inf_n = arith.constant 0xFF800000 : f32 6 | %c = arith.addf %inf_p, %inf_n : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_conflict.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0x7FC00000 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_conflict_double.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f64 { 4 | %inf_p = arith.constant 0x7FF0000000000000 : f64 5 | %inf_n = arith.constant 0xFFF0000000000000 : f64 6 | %c = arith.addf %inf_p, %inf_n : f64 7 | return %c : f64 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_conflict_double.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %c = arith.constant 0x7FF7FFFFFFFFFFFF : f64 3 | return %c : f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf = arith.constant 0x7F800000 : f32 5 | %v = arith.constant 3.0 : f32 6 | %v1 = arith.addf %inf, %v : f32 7 | %v2 = arith.addf %v, %inf : f32 8 | %c = arith.addf %v1, %v2 : f32 9 | return %c : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %v1 = arith.constant 0x7F800000 : f32 3 | %v2 = arith.constant 0x7F800000 : f32 4 | %c = arith.addf %v1, %v2 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const_double.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f64 { 4 | %inf = arith.constant 0x7FF0000000000000 : f64 5 | %v = arith.constant 3.0 : f64 6 | %v1 = arith.addf %inf, %v : f64 7 | %v2 = arith.addf %v, %inf : f64 8 | %c = arith.addf %v1, %v2 : f64 9 | return %c : f64 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const_double.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %v1 = arith.constant 0x7FF0000000000000 : f64 3 | %v2 = arith.constant 0x7FF0000000000000 : f64 4 | %c = arith.addf %v1, %v2 : f64 5 | return %c : f64 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const_neg.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf = arith.constant 0xFF800000 : f32 5 | %v = arith.constant 3.0 : f32 6 | %v1 = arith.addf %inf, %v : f32 7 | %v2 = arith.addf %v, %inf : f32 8 | %c = arith.addf %v1, %v2 : f32 9 | return %c : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const_neg.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %v1 = arith.constant 0xFF800000 : f32 3 | %v2 = arith.constant 0xFF800000 : f32 4 | %c = arith.addf %v1, %v2 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const_neg_double.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f64 { 4 | %inf = arith.constant 0xFFF0000000000000 : f64 5 | %v = arith.constant 3.0 : f64 6 | %v1 = arith.addf %inf, %v : f64 7 | %v2 = arith.addf %v, %inf : f64 8 | %c = arith.addf %v1, %v2 : f64 9 | return %c : f64 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_const_neg_double.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %v1 = arith.constant 0xFFF0000000000000 : f64 3 | %v2 = arith.constant 0xFFF0000000000000 : f64 4 | %c = arith.addf %v1, %v2 : f64 5 | return %c : f64 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_double-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // This is incorrect if at least one of arg0 and arg1 is NaN or -Inf 4 | 5 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 6 | %inf = arith.constant 0x7F800000 : f64 7 | %v1 = arith.addf %inf, %arg0 : f64 8 | %v2 = arith.addf %inf, %arg1 : f64 9 | %c = arith.addf %v1, %v2 : f64 10 | return %c : f64 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_add_double-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 2 | %inf = arith.constant 0x7F800000 : f64 3 | %c = arith.addf %inf, %inf : f64 4 | return %c: f64 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f1() -> f32 { 4 | %inf = arith.constant 0x7F800000 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.divf %inf, %v : f32 7 | return %c : f32 8 | } 9 | 10 | func.func @f2() -> f32 { 11 | %inf = arith.constant 0x7F800000 : f32 12 | %v = arith.constant 3.0 : f32 13 | %c = arith.divf %v, %inf : f32 14 | return %c : f32 15 | } 16 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f1() -> f32 { 2 | %c = arith.constant 0x7F800000 : f32 3 | return %c : f32 4 | } 5 | 6 | func.func @f2() -> f32 { 7 | %c = arith.constant 0.0 : f32 8 | return %c : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_const_neg.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf = arith.constant 0xFF800000 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.divf %inf, %v : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_const_neg.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %inf = arith.constant 0x7F800000 : f32 3 | %v = arith.constant -3.0 : f32 4 | %c = arith.divf %inf, %v : f32 5 | return %c : f32 6 | } -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_inf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf_p = arith.constant 0x7F800000 : f32 5 | %inf_n = arith.constant 0xFF800000 : f32 6 | %c = arith.divf %inf_p, %inf_n : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_inf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0x7FC00000 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_zero.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f1() -> f32 { 4 | %inf_p = arith.constant 0xFF800000 : f32 5 | %zero = arith.constant 0.0 : f32 6 | %c = arith.divf %inf_p, %zero : f32 7 | return %c : f32 8 | } 9 | 10 | func.func @f2() -> f32 { 11 | %inf_p = arith.constant 0xFF800000 : f32 12 | %zero = arith.constant 0.0 : f32 13 | %c = arith.divf %zero, %inf_p : f32 14 | return %c : f32 15 | } 16 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_div_zero.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f1() -> f32 { 2 | %c = arith.constant 0xFF800000 : f32 3 | return %c : f32 4 | } 5 | 6 | func.func @f2() -> f32 { 7 | %c = arith.constant -0.0 : f32 8 | return %c : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_conflict.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf_p = arith.constant 0x7F800000 : f32 5 | %inf_n = arith.constant 0xFF800000 : f32 6 | %c = arith.mulf %inf_p, %inf_n : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_conflict.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0xFF800000 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf = arith.constant 0x7F800000 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.mulf %inf, %v : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0x7F800000 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_const_neg.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf = arith.constant 0xFF800000 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.mulf %inf, %v : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_const_neg.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %inf = arith.constant 0x7F800000 : f32 3 | %v = arith.constant -3.0 : f32 4 | %c = arith.mulf %inf, %v : f32 5 | return %c : f32 6 | } -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_zero.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf_p = arith.constant 0xFF800000 : f32 5 | %inf_n = arith.constant 0.0 : f32 6 | %c = arith.mulf %inf_p, %inf_n : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/inf_mul_zero.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0x7FC00000 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 4 | %nan = arith.constant 0x7FC00000 : f32 5 | %v1 = arith.addf %nan, %arg0 : f32 6 | %v2 = arith.addf %nan, %arg1 : f32 7 | %c = arith.addf %v1, %v2 : f32 8 | return %c : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32, %arg1: f32) -> f32 { 2 | %nan = arith.constant 0x7FC00000 : f32 3 | %c = arith.addf %nan, %nan : f32 4 | return %c: f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %nan = arith.constant 0x7FC00000 : f32 5 | %v = arith.constant 3.0 : f32 6 | %v1 = arith.addf %nan, %v : f32 7 | %v2 = arith.addf %v, %nan : f32 8 | %c = arith.addf %v1, %v2 : f32 9 | return %c : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %v1 = arith.constant 0x7FC00000 : f32 3 | %v2 = arith.constant 0x7FC00000 : f32 4 | %c = arith.addf %v1, %v2 : f32 5 | return %c : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add_const_double.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f64 { 4 | %nan = arith.constant 0x7FF7FFFFFFFFFFFF : f64 5 | %v = arith.constant 3.0 : f64 6 | %v1 = arith.addf %nan, %v : f64 7 | %v2 = arith.addf %v, %nan : f64 8 | %c = arith.addf %v1, %v2 : f64 9 | return %c : f64 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add_const_double.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f64 { 2 | %v1 = arith.constant 0x7FF7FFFFFFFFFFFF : f64 3 | %v2 = arith.constant 0x7FF7FFFFFFFFFFFF : f64 4 | %c = arith.addf %v1, %v2 : f64 5 | return %c : f64 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add_double.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 4 | %nan = arith.constant 0x7FF7FFFFFFFFFFFF : f64 5 | %v1 = arith.addf %nan, %arg0 : f64 6 | %v2 = arith.addf %nan, %arg1 : f64 7 | %c = arith.addf %v1, %v2 : f64 8 | return %c : f64 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_add_double.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f64, %arg1: f64) -> f64 { 2 | %nan = arith.constant 0x7FF7FFFFFFFFFFFF : f64 3 | %c = arith.addf %nan, %nan : f64 4 | return %c: f64 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_div.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f1(%arg0: f32) -> f32 { 4 | %nan = arith.constant 0x7FC00000 : f32 5 | %c = arith.divf %nan, %arg0 : f32 6 | return %c : f32 7 | } 8 | 9 | func.func @f2(%arg0: f32) -> f32 { 10 | %nan = arith.constant 0x7FC00000 : f32 11 | %c = arith.divf %arg0, %nan : f32 12 | return %c : f32 13 | } -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_div.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f1(%arg0: f32) -> f32 { 2 | %nan = arith.constant 0x7FC00000 : f32 3 | return %nan: f32 4 | } 5 | 6 | func.func @f2(%arg0: f32) -> f32 { 7 | %nan = arith.constant 0x7FC00000 : f32 8 | return %nan: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_mul.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: f32) -> f32 { 4 | %nan = arith.constant 0x7FC00000 : f32 5 | %c = arith.mulf %nan, %arg0 : f32 6 | return %c : f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/nan_mul.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32) -> f32 { 2 | %nan = arith.constant 0x7FC00000 : f32 3 | return %nan: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_add-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // This is incorrect if arg0 is NaN or +-Inf 4 | 5 | func.func @f(%arg0: f32) -> f32 { 6 | %neg = arith.constant -1.0 : f32 7 | %arg0_neg = arith.mulf %arg0, %neg : f32 8 | %c = arith.addf %arg0, %arg0_neg : f32 9 | return %c : f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_add-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f32) -> f32 { 2 | %c = arith.constant 0.0 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_add_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %p = arith.constant 3.0 : f32 5 | %n = arith.constant -3.0 : f32 6 | %c = arith.addf %p, %n : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_add_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0.0 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_add_double-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // This is incorrect if arg0 is NaN or +-Inf 4 | 5 | func.func @f(%arg0: f64) -> f64 { 6 | %neg = arith.constant -1.0 : f64 7 | %arg0_neg = arith.mulf %arg0, %neg : f64 8 | %c = arith.addf %arg0, %arg0_neg : f64 9 | return %c : f64 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_add_double-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: f64) -> f64 { 2 | %c = arith.constant 0.0 : f64 3 | return %c : f64 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_const-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f32 { 4 | %p = arith.constant 3.0 : f32 5 | %n = arith.negf %p : f32 6 | return %n : f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_const-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant -5.0 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %p = arith.constant 3.0 : f32 5 | %n = arith.negf %p : f32 6 | return %n : f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/neg_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant -3.0 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/self_div_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @pos() -> f32 { 4 | %v = arith.constant 3.0 : f32 5 | %c = arith.divf %v, %v : f32 6 | return %c : f32 7 | } 8 | 9 | func.func @neg() -> f32 { 10 | %v = arith.constant 3.0 : f32 11 | %n = arith.constant -3.0 : f32 12 | %c = arith.divf %v, %n : f32 13 | return %c : f32 14 | } 15 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/self_div_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @pos() -> f32 { 2 | %c = arith.constant 1.0 : f32 3 | return %c : f32 4 | } 5 | 6 | func.func @neg() -> f32 { 7 | %c = arith.constant -1.0 : f32 8 | return %c : f32 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_eq-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @eq(%arg0: f64, %arg1: f64) -> i1 { 4 | %lhs = arith.truncf %arg0: f64 to f32 5 | %rhs = arith.truncf %arg1: f64 to f32 6 | %e = arith.cmpf "oeq", %lhs, %rhs : f32 7 | return %e: i1 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_eq-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @eq(%arg0: f64, %arg1: f64) -> i1 { 2 | %e = arith.cmpf "oeq", %arg0, %arg1 : f64 3 | return %e: i1 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_gt-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @gt(%arg0: f64, %arg1: f64) -> i1 { 4 | %lhs = arith.truncf %arg0: f64 to f32 5 | %rhs = arith.truncf %arg1: f64 to f32 6 | %e = arith.cmpf "ogt", %lhs, %rhs : f32 7 | return %e: i1 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_gt-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @gt(%arg0: f64, %arg1: f64) -> i1 { 2 | %e = arith.cmpf "ogt", %arg0, %arg1 : f64 3 | return %e: i1 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_lt-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @lt(%arg0: f64, %arg1: f64) -> i1 { 4 | %lhs = arith.truncf %arg0: f64 to f32 5 | %rhs = arith.truncf %arg1: f64 to f32 6 | %e = arith.cmpf "olt", %lhs, %rhs : f32 7 | return %e: i1 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_lt-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @lt(%arg0: f64, %arg1: f64) -> i1 { 2 | %e = arith.cmpf "olt", %arg0, %arg1 : f64 3 | return %e: i1 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_ne-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @ne(%arg0: f64, %arg1: f64) -> i1 { 4 | %lhs = arith.truncf %arg0: f64 to f32 5 | %rhs = arith.truncf %arg1: f64 to f32 6 | %e = arith.cmpf "one", %lhs, %rhs : f32 7 | return %e: i1 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_cmpf_ne-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @ne(%arg0: f64, %arg1: f64) -> i1 { 2 | %e = arith.cmpf "one", %arg0, %arg1 : f64 3 | return %e: i1 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f32 { 4 | %a = arith.constant 3.0 : f64 5 | %t = arith.truncf %a: f64 to f32 6 | %n = arith.constant -5.0 : f64 7 | %nt = arith.truncf %n: f64 to f32 8 | %s = arith.addf %t, %nt : f32 9 | return %s: f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a = arith.constant 0.0 : f32 3 | return %a: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a = arith.constant 0.0 : f32 3 | return %a: f32 4 | } 5 | 6 | func.func @tensor() -> tensor<5xf32> { 7 | %x = arith.constant dense<5.0> : tensor<5xf32> 8 | return %x: tensor<5xf32> 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_rounding-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @round() -> i1 { 4 | %c = arith.constant 3.00000012 : f64 5 | %ct = arith.truncf %c: f64 to f32 6 | %f = arith.constant 3.0000004 : f64 7 | %ft = arith.truncf %f: f64 to f32 8 | %e = arith.cmpf "oeq", %ct, %ft : f32 9 | return %e: i1 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_rounding-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @round() -> i1 { 2 | %e = arith.constant 1 : i1 3 | return %e : i1 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_rounding.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @round() -> i1 { 2 | %e = arith.constant 1 : i1 3 | return %e : i1 4 | } 5 | 6 | func.func @round_diff() -> i1 { 7 | %e = arith.constant 1 : i1 8 | return %e : i1 9 | } 10 | 11 | func.func @round_neg() -> i1 { 12 | %e = arith.constant 1 : i1 13 | return %e : i1 14 | } 15 | 16 | func.func @round_neg_diff() -> i1 { 17 | %e = arith.constant 1 : i1 18 | return %e : i1 19 | } 20 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_single_trunc-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f32 { 4 | %a = arith.constant 3.0 : f64 5 | %t = arith.truncf %a: f64 to f32 6 | return %t: f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_single_trunc-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a = arith.constant 5.0 : f32 3 | return %a: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_single_trunc.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %a = arith.constant 3.0 : f64 5 | %t = arith.truncf %a: f64 to f32 6 | return %t: f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_single_trunc.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a = arith.constant 3.0 : f32 3 | return %a: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_to_inf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %a = arith.constant 3.4028236e+38 : f64 5 | %t = arith.truncf %a: f64 to f32 6 | return %t: f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_const_to_inf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a = arith.constant 0x7F800000 : f32 3 | return %a: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_inf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %inf = arith.constant 0x7FF0000000000000 : f64 5 | %tinf = arith.truncf %inf: f64 to f32 6 | return %tinf: f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_inf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a = arith.constant 0x7F800000 : f32 3 | return %a: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_nan.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %nan = arith.constant 0x7FF7FFFFFFFFFFFF : f64 5 | %tnan = arith.truncf %nan: f64 to f32 6 | return %tnan: f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/trunc_nan.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %a = arith.constant 0x7FC00000 : f32 3 | return %a: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/zero_div_const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %z = arith.constant 0.0 : f32 5 | %v = arith.constant 3.0 : f32 6 | %c = arith.divf %z, %v : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/zero_div_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0.0 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/zero_div_zero.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %zero_p = arith.constant 0.0 : f32 5 | %zero_n = arith.constant -0.0 : f32 6 | %c = arith.divf %zero_p, %zero_n : f32 7 | return %c : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/fp-ops/zero_div_zero.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %c = arith.constant 0x7FC00000 : f32 3 | return %c : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/cast_to_dyn-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func private @dyn_tensor(%t: tensor) -> f32 4 | 5 | func.func @dim_mismatch() -> f32 { 6 | %zt = arith.constant sparse<[[0], [1], [2], [3], [4]], [0, 0, 0, 0, 0]> : tensor<5xi32> 7 | %zdt = tensor.cast %zt: tensor<5xi32> to tensor 8 | %r = func.call @dyn_tensor(%zdt): (tensor) -> f32 9 | return %r: f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/cast_to_dyn-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func private @dyn_tensor(%t: tensor) -> f32 2 | 3 | func.func @dim_mismatch() -> f32 { 4 | %zt = arith.constant sparse<[[0], [1], [2]], [0, 0, 0]> : tensor<3xi32> 5 | %zdt = tensor.cast %zt: tensor<3xi32> to tensor 6 | %r = func.call @dyn_tensor(%zdt): (tensor) -> f32 7 | return %r: f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/fn_arg_dims.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --use-fn-argument-dims=dyn_tensor_1@0 3 | 4 | func.func private @dyn_tensor_1(%v: tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 5 | 6 | func.func @tensor_dim(%v: tensor<3x?x?xf32>) -> index { 7 | %t = func.call @dyn_tensor_1(%v): (tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 8 | %c = arith.constant 1: index 9 | %r = tensor.dim %v, %c: tensor<3x?x?xf32> 10 | return %r: index 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/fn_arg_dims.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func private @dyn_tensor_1(%v: tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 2 | 3 | func.func @tensor_dim(%v: tensor<3x?x?xf32>) -> index { 4 | %t = func.call @dyn_tensor_1(%v): (tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 5 | %c = arith.constant 1: index 6 | %r = tensor.dim %t, %c: tensor<3x?x?xf32> 7 | return %r: index 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/no_fn_arg_dims-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func private @dyn_tensor_1(%v: tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 4 | 5 | func.func @tensor_dim(%v: tensor<3x?x?xf32>) -> index { 6 | %t = func.call @dyn_tensor_1(%v): (tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 7 | %c = arith.constant 1: index 8 | %r = tensor.dim %v, %c: tensor<3x?x?xf32> 9 | return %r: index 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/no_fn_arg_dims-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func private @dyn_tensor_1(%v: tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 2 | 3 | func.func @tensor_dim(%v: tensor<3x?x?xf32>) -> index { 4 | %t = func.call @dyn_tensor_1(%v): (tensor<3x?x?xf32>) -> tensor<3x?x?xf32> 5 | %c = arith.constant 1: index 6 | %r = tensor.dim %t, %c: tensor<3x?x?xf32> 7 | return %r: index 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/scalar_chain-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func private @simpl(%v: f32) -> f32 4 | 5 | func.func @chain(%v: f32) -> f32 { 6 | %r1 = func.call @simpl(%v): (f32) -> f32 7 | %r2 = func.call @simpl(%r1): (f32) -> f32 8 | return %r2: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/scalar_chain-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func private @simpl(%v: f32) -> f32 2 | 3 | func.func @chain(%v: f32) -> f32 { 4 | %r1 = func.call @simpl(%v): (f32) -> f32 5 | return %r1: f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/scalar_comm-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func private @simpl2(%v1: f32, %v2: f32) -> f32 4 | 5 | func.func @comm(%v1: f32, %v2: f32) -> f32 { 6 | %r = func.call @simpl2(%v1, %v2): (f32, f32) -> f32 7 | return %r: f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/scalar_comm-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func private @simpl2(%v1: f32, %v2: f32) -> f32 2 | 3 | func.func @comm(%v1: f32, %v2: f32) -> f32 { 4 | %r = func.call @simpl2(%v2, %v1): (f32, f32) -> f32 5 | return %r: f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/tensor-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func private @linear_tensor(%t: tensor<5xf32>) -> f32 4 | 5 | func.func @different_tensor(%v: tensor<5xf32>) -> f32 { 6 | %i = arith.constant 4: index 7 | %c = arith.constant 5.0: f32 8 | %mv = tensor.insert %c into %v[%i]: tensor<5xf32> 9 | %r = func.call @linear_tensor(%mv): (tensor<5xf32>) -> f32 10 | return %r: f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/func-ops/tensor-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func private @linear_tensor(%t: tensor<5xf32>) -> f32 2 | 3 | func.func @different_tensor(%v: tensor<5xf32>) -> f32 { 4 | %i = arith.constant 4: index 5 | %c = arith.constant 3.0: f32 6 | %mv = tensor.insert %c into %v[%i]: tensor<5xf32> 7 | %r = func.call @linear_tensor(%mv): (tensor<5xf32>) -> f32 8 | return %r: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/convert-elementwise-cmpf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @cmpf(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = arith.cmpf olt, %arg0, %arg1 : tensor 5 | return %0 : tensor 6 | } 7 | 8 | // How to reproduce tgt: 9 | // mlir-opt -convert-elementwise-to-linalg 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/convert-elementwise-select.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @select(%arg0: tensor, %arg1: tensor, %arg2: tensor) -> tensor { 4 | %0= arith.select %arg0, %arg1, %arg2 : tensor, tensor 5 | return %0 : tensor 6 | } 7 | 8 | // How to reproduce tgt: 9 | // mlir-opt -convert-elementwise-to-linalg 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/convert-elementwise-select2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @select(%arg0: tensor<8xi1>, %arg1: tensor<8xi32>, %arg2: tensor<8xi32>) -> tensor<8xi32> { 4 | %0= arith.select %arg0, %arg1, %arg2 : tensor<8xi1>, tensor<8xi32> 5 | return %0 : tensor<8xi32> 6 | } 7 | 8 | // How to reproduce tgt: 9 | // mlir-opt -convert-elementwise-to-linalg 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/convert-elementwise-select3.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @select(%arg0: tensor, %arg1: tensor, %arg2: tensor) -> tensor { 4 | %0= arith.select %arg0, %arg1, %arg2 : tensor, tensor 5 | return %0 : tensor 6 | } 7 | 8 | // How to reproduce tgt: 9 | // mlir-opt -convert-elementwise-to-linalg 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/empty.src.mlir: -------------------------------------------------------------------------------- 1 | // UNSUPPORTED 2 | 3 | #accesses = [ 4 | affine_map<(i, j) -> (i, j)> 5 | ] 6 | #trait = { 7 | indexing_maps = #accesses, 8 | iterator_types = ["parallel", "parallel"] 9 | } 10 | func.func @dead_linalg_tensor(%arg0 : tensor<7x7xi32>) { 11 | %0 = linalg.generic #trait outs(%arg0 : tensor<7x7xi32>) { 12 | ^bb(%3: i32) : 13 | linalg.yield %3 : i32 14 | } -> tensor<7x7xi32> 15 | return 16 | } 17 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/empty.tgt.mlir: -------------------------------------------------------------------------------- 1 | #accesses = [ 2 | affine_map<(i, j) -> (i, j)> 3 | ] 4 | #trait = { 5 | indexing_maps = #accesses, 6 | iterator_types = ["parallel", "parallel"] 7 | } 8 | func.func @dead_linalg_tensor(%arg0 : tensor<7x7xi32>) { 9 | %0 = linalg.generic #trait outs(%arg0 : tensor<7x7xi32>) { 10 | ^bb(%3: i32) : 11 | linalg.yield %3 : i32 12 | } -> tensor<7x7xi32> 13 | return 14 | } 15 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/mult_result.tgt.mlir: -------------------------------------------------------------------------------- 1 | #map = affine_map<(d0) -> (d0)> 2 | module { 3 | func.func @generic_mult2(%arg0: tensor<5xf32>, %arg1: tensor<5xf32>,%arg2: tensor<5xf32>) -> (tensor<5xf32>, tensor<5xf32>) { 4 | return %arg0, %arg2 : tensor<5xf32>, tensor<5xf32> 5 | } 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/nested.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @dumb_loop(%arg0: tensor) -> tensor { 2 | return %arg0 : tensor 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/output-value-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: tensor<10x10xi32>) -> tensor<10x10xi32> { 2 | %not_three= arith.constant 4 : i32 3 | %init_tensor = tensor.empty () : tensor<10x10xi32> 4 | %filled = linalg.fill ins(%not_three: i32) outs(%init_tensor: tensor<10x10xi32>) -> tensor<10x10xi32> 5 | return %filled : tensor<10x10xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/output-value.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: tensor<10x10xi32>) -> tensor<10x10xi32> { 2 | %three= arith.constant 3 : i32 3 | %init_tensor = tensor.empty () : tensor<10x10xi32> 4 | %filled = linalg.fill ins(%three: i32) outs(%init_tensor: tensor<10x10xi32>) -> tensor<10x10xi32> 5 | return %filled : tensor<10x10xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/sum-int-unroll.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @sum() -> tensor 2 | { 3 | %fifty = arith.constant 50: i8 4 | %zero = arith.constant 0 : i8 5 | %i = tensor.empty (): tensor 6 | %t = linalg.fill ins(%zero: i8) outs(%i: tensor) -> tensor 7 | %t2 = tensor.insert %fifty into %t[]: tensor 8 | return %t2: tensor 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/sum-unit-tensor-ub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @sum(%x: tensor<1xf32>) -> f32 2 | { 3 | %c0 = arith.constant 0 : index 4 | %elem = tensor.extract %x[%c0]: tensor<1xf32> 5 | return %elem : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/linalg-loops/sum-unit-tensor.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @sum(%x: tensor<1xf32>) -> f32 2 | { 3 | %c0 = arith.constant 0 : index 4 | %elem = tensor.extract %x[%c0]: tensor<1xf32> 5 | return %elem : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/conv-uninit.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @conv(%filter: memref<3x3x1x1xf32>, 2 | %output: memref<1x1x1x1xf32>) { 3 | %input = memref.alloc(): memref<1x3x3x1xf32> 4 | linalg.conv_2d_nhwc_hwcf 5 | {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} 6 | ins(%input, %filter: memref<1x3x3x1xf32>, memref<3x3x1x1xf32>) 7 | outs(%output: memref<1x1x1x1xf32>) 8 | return 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/convolution_constfold.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @conv() -> tensor<1x1x1x1xf32> { 2 | %0 = arith.constant dense<[[[[1.0]]]]> : tensor<1x1x1x1xf32> 3 | return %0 : tensor<1x1x1x1xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/dot.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%a: tensor<100xf32>, %b: tensor<100xf32>) -> tensor { 4 | %i = tensor.empty (): tensor 5 | %zero = arith.constant -0.0 : f32 6 | %filled = linalg.fill ins(%zero: f32) outs(%i: tensor) -> tensor 7 | %e = linalg.dot ins(%a, %b : tensor<100xf32>,tensor<100xf32>) 8 | outs(%filled: tensor) -> tensor 9 | return %e : tensor 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/dot2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%a: tensor, %b: tensor) -> tensor { 4 | %zero = arith.constant -0.0 : f32 5 | %i = tensor.empty () : tensor 6 | %outty = linalg.fill ins(%zero: f32) outs(%i: tensor) -> tensor 7 | %e = linalg.dot ins(%a, %b : tensor,tensor) 8 | outs(%outty: tensor) -> tensor 9 | return %e : tensor 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/dot_assoc_varlen.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Only an array of constant length is supported" 2 | // ARGS: --associative 3 | 4 | func.func @f(%a: tensor, %b: tensor) -> tensor { 5 | %i = tensor.empty (): tensor 6 | %res = linalg.dot ins(%a, %b : tensor,tensor) 7 | outs(%i: tensor) -> tensor 8 | return %res : tensor 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/dot_assoc_varlen.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: tensor, %b: tensor) -> tensor { 2 | %i = tensor.empty (): tensor 3 | %res = linalg.dot ins(%a, %a : tensor,tensor) 4 | outs(%i: tensor) -> tensor 5 | return %res : tensor 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/dot_commutative.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%a: tensor<100xf32>, %b: tensor<100xf32>) -> tensor { 4 | %i = tensor.empty (): tensor 5 | %e = linalg.dot ins(%a, %b : tensor<100xf32>,tensor<100xf32>) 6 | outs(%i: tensor) -> tensor 7 | return %e : tensor 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/dot_constfold.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %c0 = arith.constant 1.0: f32 5 | return %c0 : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/fill.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg: tensor<3x3xf32>) -> tensor<3x3xf32> { 4 | %t = tensor.empty (): tensor<3x3xf32> 5 | %c0 = arith.constant 0.0: f32 6 | %res = linalg.fill ins(%c0: f32) outs(%t: tensor<3x3xf32>) -> tensor<3x3xf32> 7 | return %res: tensor<3x3xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/fill.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg: tensor<3x3xf32>) -> tensor<3x3xf32> { 2 | %c0 = arith.constant 0.0: f32 3 | %res = linalg.fill ins(%c0: f32) outs(%arg: tensor<3x3xf32>) -> tensor<3x3xf32> 4 | return %res: tensor<3x3xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/init_tensor.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Return value mismatch" 2 | 3 | func.func @f() -> index { 4 | %c0 = arith.constant 0: index 5 | %c10 = arith.constant 10: index 6 | %v = tensor.empty (%c10): tensor 7 | %d = tensor.dim %v, %c0: tensor 8 | return %d: index 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/init_tensor.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> index { 2 | %c0 = arith.constant 0: index 3 | %c10 = arith.constant 20: index 4 | %v = tensor.empty (%c10): tensor 5 | %d = tensor.dim %v, %c0: tensor 6 | return %d: index 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/init_tensor_cast.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> (tensor<4x5x?xf32>) { 4 | %c6 = arith.constant 6 : index 5 | %0 = tensor.empty (%c6) : tensor<4x5x?xf32> 6 | return %0 : tensor<4x5x?xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/init_tensor_cast.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4x5x?xf32> { 2 | %0 = tensor.empty () : tensor<4x5x6xf32> 3 | %1 = tensor.cast %0 : tensor<4x5x6xf32> to tensor<4x5x?xf32> 4 | return %1 : tensor<4x5x?xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/matmul-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%A : tensor<8x4xf32>, %B: tensor<4x16xf32>, %C: tensor<8x16xf32>, %D: tensor<8x16xf32>) -> tensor<8x16xf32> { 4 | %0 = linalg.matmul ins(%A, %B: tensor<8x4xf32>, tensor<4x16xf32>) 5 | outs(%C: tensor<8x16xf32>) -> tensor<8x16xf32> 6 | return %0: tensor<8x16xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/matmul-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%A : tensor<8x4xf32>, %B: tensor<4x16xf32>, %C: tensor<8x16xf32>, %D: tensor<8x16xf32>) -> tensor<8x16xf32> { 2 | %0 = linalg.matmul ins(%A, %B: tensor<8x4xf32>, tensor<4x16xf32>) 3 | outs(%D: tensor<8x16xf32>) -> tensor<8x16xf32> 4 | return %0: tensor<8x16xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/memref_matmul_bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a : memref<8x4xf32>, %b: memref<4x2xf32>, %c: memref<8x2xf32>) -> tensor<8x2xf32> { 2 | linalg.matmul ins(%a, %b: memref<8x4xf32>, memref<4x2xf32>) outs(%c: memref<8x2xf32>) 3 | %tc = bufferization.to_tensor %c : memref<8x2xf32> 4 | return %tc: tensor<8x2xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/linalg-ops/pooling_unsupported1.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @pooling_nhwc_i32_max(%arg0: memref<1x4x4x1xi32>, %arg1: memref<3x3xi32>, %arg2: memref<1x2x2x1xi32>) { 3 | linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>} ins(%arg0, %arg1 : memref<1x4x4x1xi32>, memref<3x3xi32>) outs(%arg2 : memref<1x2x2x1xi32>) 4 | return 5 | } 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/math-ops/abs.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @int(%x: i32) -> i32 { 4 | %y = math.absi %x: i32 5 | %z = math.absi %y: i32 6 | return %z: i32 7 | } 8 | 9 | func.func @fp(%x: f32) -> f32 { 10 | %y = math.absf %x: f32 11 | %z = math.absf %y: f32 12 | return %z: f32 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /tests/litmus/math-ops/abs.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @int(%x: i32) -> i32 { 2 | %y = math.absi %x: i32 3 | return %y: i32 4 | } 5 | 6 | func.func @fp(%x: f32) -> f32 { 7 | %y = math.absf %x: f32 8 | return %y: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/math-ops/abs_mul.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: f32, %y: f32) -> f32 { 4 | %p = math.absf %x: f32 5 | %q = math.absf %y: f32 6 | %w = arith.mulf %p, %q: f32 7 | return %w: f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/math-ops/abs_mul.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: f32, %y: f32) -> f32 { 4 | %z = arith.mulf %x, %y: f32 5 | %w = math.absf %z: f32 6 | return %w: f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/math-ops/exp.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: f32) -> f32 { 4 | %y = math.exp %x: f32 5 | return %y: f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/math-ops/exp.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x: f32) -> f32 { 2 | %y = math.exp %x: f32 3 | return %y: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc-alloc-noalias.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%idx: index, %idx2: index) -> (f32, f32) { 2 | %f1 = arith.constant 1.0: f32 3 | %f2 = arith.constant 2.0: f32 4 | return %f1, %f2: f32, f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc-arg-noalias-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg: memref, %idx: index, %idx2: index) -> (f32, f32) { 2 | %f1 = arith.constant 1.0: f32 3 | %f2 = arith.constant 2.0: f32 4 | %c1 = arith.constant 0: index 5 | %c2 = arith.constant 2: index 6 | 7 | //memref.store %f1, %arg[%idx]: memref 8 | return %f1, %f2: f32, f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc-arg-noalias.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg: memref, %idx: index, %idx2: index) -> (f32, f32) { 2 | %f1 = arith.constant 1.0: f32 3 | %f2 = arith.constant 2.0: f32 4 | %c1 = arith.constant 0: index 5 | %c2 = arith.constant 2: index 6 | 7 | memref.store %f1, %arg[%idx]: memref 8 | return %f1, %f2: f32, f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f32 { 4 | %ptr = memref.alloc(): memref<8x64xf32> 5 | %f0 = arith.constant 1.0: f32 6 | %c1 = arith.constant 1: index 7 | %c2 = arith.constant 2: index 8 | memref.store %f0, %ptr[%c1, %c2]: memref<8x64xf32> 9 | %v = memref.load %ptr[%c1, %c2]: memref<8x64xf32> 10 | return %v: f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %f0 = arith.constant 2.0: f32 3 | return %f0: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc-varsize.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @f(%sz: index) -> (){ 4 | %ptr = memref.alloc(%sz): memref 5 | memref.load %ptr[%sz]: memref 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc-varsize.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%sz: index) -> (){ 2 | return 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %ptr = memref.alloc(): memref<8x64xf32> 5 | %f0 = arith.constant 1.0: f32 6 | %c1 = arith.constant 1: index 7 | %c2 = arith.constant 2: index 8 | memref.store %f0, %ptr[%c1, %c2]: memref<8x64xf32> 9 | %v = memref.load %ptr[%c1, %c2]: memref<8x64xf32> 10 | return %v: f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloc.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %f0 = arith.constant 1.0: f32 3 | return %f0: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloca.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %ptr = memref.alloca(): memref<8x64xf32> 5 | %f0 = arith.constant 1.0: f32 6 | %c1 = arith.constant 1: index 7 | %c2 = arith.constant 2: index 8 | memref.store %f0, %ptr[%c1, %c2]: memref<8x64xf32> 9 | %v = memref.load %ptr[%c1, %c2]: memref<8x64xf32> 10 | return %v: f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/alloca.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %f0 = arith.constant 1.0: f32 3 | return %f0: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/collapse-shape.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg : memref<8x4x2xf32>) -> tensor<8x8xf32> { 4 | %tensor = bufferization.to_tensor %arg : memref<8x4x2xf32> 5 | %ret = tensor.collapse_shape %tensor [[0], [1, 2]] : tensor<8x4x2xf32> into tensor<8x8xf32> 6 | return %ret: tensor<8x8xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/collapse-shape.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg : memref<8x4x2xf32>) -> tensor<8x8xf32> { 2 | %memref = memref.collapse_shape %arg [[0], [1, 2]] : memref<8x4x2xf32> into memref<8x8xf32> 3 | %ret = bufferization.to_tensor %memref : memref<8x8xf32> 4 | return %ret: tensor<8x8xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/copy-fill.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @copy(%m1: memref<10x10xf32>, %m2: memref<10x10xf32>) 4 | { 5 | %c0 = arith.constant 0.0: f32 6 | linalg.fill ins(%c0: f32) outs(%m1: memref<10x10xf32>) 7 | memref.copy %m1, %m2 : memref<10x10xf32> to memref<10x10xf32> 8 | return 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/copy-fill.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @copy(%m1: memref<10x10xf32>, %m2: memref<10x10xf32>) 2 | { 3 | %c0 = arith.constant 0.0: f32 4 | linalg.fill ins(%c0: f32) outs(%m1: memref<10x10xf32>) 5 | linalg.fill ins(%c0: f32) outs(%m2: memref<10x10xf32>) 6 | return 7 | } 8 | 9 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-alloca.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @f() { 4 | %ptr = memref.alloca(): memref<8x64xf32> 5 | memref.dealloc %ptr: memref<8x64xf32> 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-alloca.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() { 2 | return 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f32 { 4 | %ptr = memref.alloc(): memref<8x64xf32> 5 | %f0 = arith.constant 1.0: f32 6 | %c1 = arith.constant 1: index 7 | %c2 = arith.constant 2: index 8 | memref.store %f0, %ptr[%c1, %c2]: memref<8x64xf32> 9 | %v = memref.load %ptr[%c1, %c2]: memref<8x64xf32> 10 | memref.dealloc %ptr: memref<8x64xf32> 11 | return %v: f32 12 | } 13 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %ptr = memref.alloc(): memref<8x64xf32> 3 | %f0 = arith.constant 1.0: f32 4 | %c1 = arith.constant 1: index 5 | %c2 = arith.constant 2: index 6 | memref.store %f0, %ptr[%c1, %c2]: memref<8x64xf32> 7 | memref.dealloc %ptr: memref<8x64xf32> 8 | %v = memref.load %ptr[%c1, %c2]: memref<8x64xf32> 9 | return %v: f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-bad2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() { 4 | %ptr = memref.alloc(): memref<8x64xf32> 5 | memref.dealloc %ptr: memref<8x64xf32> 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-bad2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() { 2 | %f0 = arith.constant 1.0: f32 3 | %c1 = arith.constant 1: index 4 | %c2 = arith.constant 2: index 5 | %ptr = memref.alloc(): memref<8x64xf32> 6 | memref.dealloc %ptr: memref<8x64xf32> 7 | memref.store %f0, %ptr[%c1, %c2]: memref<8x64xf32> 8 | return 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-view-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // subview ptr cannot be freed 4 | func.func @f() { 5 | %ptr = memref.alloc(): memref<8x64xf32> 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc-view-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() { 4 | %ptr = memref.alloc(): memref<8x64xf32> 5 | %ptr0 = memref.subview %ptr[0,0][8,64][1,1]: memref<8x64xf32> to memref<8x64xf32> 6 | memref.dealloc %ptr0: memref<8x64xf32> 7 | return 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %ptr = memref.alloc(): memref<8x64xf32> 5 | %f0 = arith.constant 1.0: f32 6 | %c1 = arith.constant 1: index 7 | %c2 = arith.constant 2: index 8 | memref.store %f0, %ptr[%c1, %c2]: memref<8x64xf32> 9 | %v = memref.load %ptr[%c1, %c2]: memref<8x64xf32> 10 | memref.dealloc %ptr: memref<8x64xf32> 11 | return %v: f32 12 | } 13 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dealloc.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %f0 = arith.constant 1.0: f32 3 | return %f0: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dim.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%A: memref<4x?xf32>) -> index { 4 | %c1 = arith.constant 0 : index 5 | %y = memref.dim %A, %c1 : memref<4x?xf32> 6 | return %y: index 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/dim.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%A: memref<4x?xf32>) -> index { 2 | %c1 = arith.constant 4 : index 3 | return %c1: index 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/expand-collapse-shape.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg : memref<1x2xf32>) -> memref<1x2xf32> { 4 | %0 = memref.expand_shape %arg [[0, 1], [2]] output_shape [1,1,2] : memref<1x2xf32> into memref<1x1x2xf32> 5 | %1 = memref.collapse_shape %0 [[0, 1], [2]] : memref<1x1x2xf32> into memref<1x2xf32> 6 | return %1: memref<1x2xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/expand-collapse-shape.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg : memref<1x2xf32>) -> memref<1x2xf32> { 2 | return %arg: memref<1x2xf32> 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/expand-shape.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg : memref<1x2xf32>) -> tensor<1x1x2xf32> { 4 | %tensor = bufferization.to_tensor %arg : memref<1x2xf32> 5 | %ret = tensor.expand_shape %tensor [[0, 1], [2]] output_shape [1,1,2] : tensor<1x2xf32> into tensor<1x1x2xf32> 6 | return %ret: tensor<1x1x2xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/expand-shape.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg : memref<1x2xf32>) -> tensor<1x1x2xf32> { 2 | %memref = memref.expand_shape %arg [[0, 1], [2]] output_shape [1,1,2] : memref<1x2xf32> into memref<1x1x2xf32> 3 | %ret = bufferization.to_tensor %memref : memref<1x1x2xf32> 4 | return %ret: tensor<1x1x2xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-arg-alias-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // %a may point to a block that isn't @gv0 4 | 5 | memref.global @gv0 : memref<2xf32> 6 | 7 | func.func @f(%a: memref<2xf32>) -> memref<2xf32> { 8 | %gv = memref.get_global @gv0: memref<2xf32> 9 | return %gv: memref<2xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-arg-alias-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | memref.global @gv0 : memref<2xf32> 2 | 3 | func.func @f(%a: memref<2xf32>) -> memref<2xf32> { 4 | return %a: memref<2xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-const-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | memref.global constant @gv0 : memref<2x3xf32> = dense<[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]> 4 | 5 | func.func @f() -> f32 { 6 | %zero = arith.constant 0: index 7 | %two = arith.constant 2: index 8 | %gv = memref.get_global @gv0: memref<2x3xf32> 9 | %v = memref.load %gv[%zero, %two]: memref<2x3xf32> 10 | return %v: f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-const-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %res = arith.constant 3.0: f32 3 | return %res: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-const-intro.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %a = arith.constant 5.0: f32 5 | return %a: f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-const-intro.tgt.mlir: -------------------------------------------------------------------------------- 1 | memref.global constant @gv0 : memref<2x3xf32> = dense<[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]> 2 | 3 | func.func @f() -> f32 { 4 | %one = arith.constant 1: index 5 | %two = arith.constant 2: index 6 | %gv = memref.get_global @gv0: memref<2x3xf32> 7 | %v = memref.load %gv[%one, %two]: memref<2x3xf32> 8 | return %v: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | memref.global constant @gv0 : memref<2x3xf32> = dense<[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]> 4 | 5 | func.func @f() -> f32 { 6 | %zero = arith.constant 0: index 7 | %two = arith.constant 2: index 8 | %gv = memref.get_global @gv0: memref<2x3xf32> 9 | %v = memref.load %gv[%zero, %two]: memref<2x3xf32> 10 | return %v: f32 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global-const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %res = arith.constant 2.0: f32 3 | return %res: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | memref.global @gv0 : memref<2xf32> 4 | 5 | func.func @f(%a: memref<2xf32>, %i: index, %v: f32) -> f32 { 6 | %gv = memref.get_global @gv0: memref<2xf32> 7 | memref.store %v, %gv[%i]: memref<2xf32> 8 | %v2 = memref.load %gv[%i]: memref<2xf32> 9 | return %v2: f32 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/global.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | memref.global @gv0 : memref<2xf32> 4 | 5 | func.func @f(%a: memref<2xf32>, %i: index, %v: f32) -> f32 { 6 | %gv = memref.get_global @gv0: memref<2xf32> 7 | memref.store %v, %gv[%i]: memref<2xf32> 8 | return %v: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/load-intro-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // Introducing memref.load %a is incorrect because %a may not be dereferenceable 4 | 5 | func.func @f(%a: memref<1xf32>) { 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/load-intro-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: memref<1xf32>) { 2 | %c0 = arith.constant 0: index 3 | %v = memref.load %a[%c0]: memref<1xf32> 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/load-intro-bad2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%a: memref<1xf32>) { 4 | %c0 = arith.constant 0: index 5 | %v = arith.constant 1.1: f32 6 | memref.store %v, %a[%c0]: memref<1xf32> 7 | return 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/load-intro-bad2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: memref<1xf32>) { 2 | %c0 = arith.constant 0: index 3 | // This is UB when %a[0] is uninitialized. 4 | %dummy = memref.load %a[%c0]: memref<1xf32> 5 | %v = arith.constant 1.1: f32 6 | memref.store %v, %a[%c0]: memref<1xf32> 7 | return 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/memref-inputs-simple.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: -memref-inputs-simple 3 | 4 | func.func @f(%a: memref, %b: memref) { 5 | %c0 = arith.constant 0: i32 6 | %c1 = arith.constant 1: i32 7 | memref.store %c0, %a[]: memref 8 | memref.store %c1, %b[]: memref 9 | return 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/memref-inputs-simple.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: memref, %b: memref) { 2 | %c0 = arith.constant 0: i32 3 | %c1 = arith.constant 1: i32 4 | memref.store %c1, %b[]: memref 5 | memref.store %c0, %a[]: memref 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/nonidentity-layout-store-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg: memref<1x1xf32, affine_map<(d0, d1) -> (d0 * 4 + d1 + 16)>>) { 2 | %one = arith.constant 1.0:f32 3 | %two = arith.constant 2.0:f32 4 | linalg.fill ins(%one:f32) outs(%arg: memref<1x1xf32, affine_map<(d0, d1) -> (d0 * 4 + d1 + 16)>>) 5 | return 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/nonidentity-layout-store.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg: memref<1x1xf32, affine_map<(d0, d1) -> (d0 * 4 + d1 + 16)>>) { 2 | %one = arith.constant 1.0:f32 3 | %two = arith.constant 2.0:f32 4 | //linalg.fill ins(%one:f32) outs(%arg: memref<1x1xf32, affine_map<(d0, d1) -> (d0 * 4 + d1 + 16)>>) 5 | linalg.fill ins(%two:f32) outs(%arg: memref<1x1xf32, affine_map<(d0, d1) -> (d0 * 4 + d1 + 16)>>) 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/subview_inbounds-noub.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | // Show that subview does not raise UB if the resulting memref is out-of-bounds 4 | func.func @subview(%arg: memref<4x4xf32>) -> i32 { 5 | %c0 = arith.constant 0: i32 6 | %f = memref.subview %arg[4, 0][1, 1][1, 1] : memref<4x4xf32> to memref<1x1xf32, affine_map<(d0, d1) -> (d0 * 4 + d1 + 16)>> 7 | return %c0: i32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/subview_inbounds-noub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @subview(%arg: memref<4x4xf32>) -> i32 { 2 | %c1 = arith.constant 1: i32 3 | return %c1: i32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/subview_out_of_bounds.tgt.mlir: -------------------------------------------------------------------------------- 1 | 2 | func.func @fold_rank_reducing_subview_with_load(%arg0: memref) -> f32 { 3 | %c1 = arith.constant 1 : index 4 | %c0 = arith.constant 0 : index 5 | %0 = memref.load %arg0[%c1, %c0] : memref 6 | return %0 : f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/subview_reduce_rank.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @subview(%arg: memref<8x16x4xf32>) -> f32 { 4 | %c0 = arith.constant 0 : index 5 | %c1 = arith.constant 1 : index 6 | %1 = memref.load %arg[%c0, %c1, %c1]: memref<8x16x4xf32> 7 | return %1 : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/memref-ops/subview_reduce_rank.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @subview(%arg: memref<8x16x4xf32>) -> f32 { 2 | %c1 = arith.constant 1 : index 3 | %1 = memref.subview %arg[0, 0, 0][1, 16, 4][1, 1, 1] : memref<8x16x4xf32> to memref<16x4xf32> 4 | %2 = memref.load %1[%c1, %c1]: memref<16x4xf32> 5 | return %2 : f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/refinement/memory_mismatch.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Memory mismatch" 2 | 3 | func.func @test(%arg0 : memref<2x3xf32>) -> f32 4 | { 5 | %index = arith.constant 0 : index 6 | %val = arith.constant 1.000000e-03 : f32 7 | memref.store %val, %arg0[%index, %index] : memref<2x3xf32> 8 | return %val : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/refinement/memory_mismatch.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test(%arg0 : memref<2x3xf32>) -> f32 2 | { 3 | %val = arith.constant 1.000000e-03 : f32 4 | return %val : f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/refinement/multiple-ret.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Return value mismatch (2/2)" 2 | 3 | func.func @f() -> (f32, f32) { 4 | %c0 = arith.constant 0.0: f32 5 | %c1 = arith.constant 1.0: f32 6 | return %c0, %c1: f32, f32 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/refinement/multiple-ret.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> (f32, f32) { 2 | %c0 = arith.constant 0.0: f32 3 | %c2 = arith.constant 2.0: f32 4 | return %c0, %c2: f32, f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/refinement/remove_memref_dealloc.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | // Removing dealloc is always okay because it makes the whole context more defined 4 | 5 | func.func @test(%arg : memref<2x3xf32>) 6 | { 7 | memref.dealloc %arg: memref<2x3xf32> 8 | return 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/refinement/remove_memref_dealloc.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test(%arg0 : memref<2x3xf32>) 2 | { 3 | return 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/refinement/remove_memref_load.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @test(%arg : memref<2x3xf32>) -> f32 4 | { 5 | %val = arith.constant 1.000000e-03 : f32 6 | %index = arith.constant 0 : index 7 | %origin = memref.load %arg[%index, %index] : memref<2x3xf32> 8 | return %val : f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/refinement/remove_memref_load.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test(%arg0 : memref<2x3xf32>) -> f32 2 | { 3 | %val = arith.constant 1.000000e-03 : f32 4 | return %val : f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/refinement/remove_memref_tensor_load.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @test(%arg : memref<2x3xf32>) -> f32 4 | { 5 | %val = arith.constant 1.000000e-03 : f32 6 | %tensor = bufferization.to_tensor %arg : memref<2x3xf32> 7 | return %val : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/refinement/remove_memref_tensor_load.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test(%arg0 : memref<2x3xf32>) -> f32 2 | { 3 | %val = arith.constant 1.000000e-03 : f32 4 | return %val : f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/refinement/size-mismatch.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Return value mismatch" 2 | // SKIP-IDCHECK 3 | 4 | func.func @f() -> tensor { 5 | %c10 = arith.constant 10: index 6 | %v = tensor.empty (%c10): tensor 7 | return %v: tensor 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/refinement/size-mismatch.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor { 2 | %c20 = arith.constant 20: index 3 | %v = tensor.empty (%c20): tensor 4 | return %v: tensor 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/sparsetensor-ops/convert.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | #CSR = #sparse_tensor.encoding<{ 4 | map = (d0, d1) -> (d1 : dense, d0 : compressed) 5 | }> 6 | 7 | func.func @f(%x: tensor) -> tensor 8 | { 9 | %y = sparse_tensor.convert %x: tensor to tensor 10 | %z = sparse_tensor.convert %y: tensor to tensor 11 | return %x: tensor 12 | } 13 | -------------------------------------------------------------------------------- /tests/litmus/sparsetensor-ops/convert.tgt.mlir: -------------------------------------------------------------------------------- 1 | #CSR = #sparse_tensor.encoding<{ 2 | map = (d0, d1) -> (d1 : dense, d0 : compressed) 3 | }> 4 | 5 | func.func @f(%x: tensor) -> tensor 6 | { 7 | return %x: tensor 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/sparsetensor-ops/ordering-doesnt-matter.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | #CSR = #sparse_tensor.encoding<{ 4 | map = (d0, d1) -> (d1: dense, d0: compressed) 5 | }> 6 | 7 | func.func @f(%x: tensor) -> f32 8 | { 9 | %c0 = arith.constant 0: index 10 | %c1 = arith.constant 1: index 11 | %res = tensor.extract %x[%c0, %c1]: tensor 12 | return %res: f32 13 | } 14 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-limit-verbose.src.mlir: -------------------------------------------------------------------------------- 1 | // ARGS: -verbose -max-const-tensor-size=3 2 | // EXPECT: "Too many elements: 15 > 3" 3 | 4 | func.func @f() -> tensor<5x3xf32> { 5 | %cst = arith.constant dense<[[0.0, 1.0, 2.0], 6 | [3.0, 4.0, 5.0], 7 | [6.0, 7.0, 8.0], 8 | [9.0, 10.0, 11.0], 9 | [12.0, 13.0, 14.0]]>: tensor<5x3xf32> 10 | return %cst: tensor<5x3xf32> 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-limit-verbose.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<5x3xf32> { 2 | %cst = arith.constant dense<[[0.0, 1.0, 2.0], 3 | [3.0, 4.0, 5.0], 4 | [6.0, 7.0, 8.0], 5 | [9.0, 10.0, 11.0], 6 | [12.0, 13.0, 14.0]]>: tensor<5x3xf32> 7 | return %cst: tensor<5x3xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-limit-verbose2.src.mlir: -------------------------------------------------------------------------------- 1 | // ARGS: -verbose -max-const-tensor-size=3 2 | // EXPECT: "skipped: %cst = arith.constant" 3 | 4 | func.func @f() -> tensor<5x3xf32> { 5 | %cst = arith.constant dense<[[0.0, 1.0, 2.0], 6 | [3.0, 4.0, 5.0], 7 | [6.0, 7.0, 8.0], 8 | [9.0, 10.0, 11.0], 9 | [12.0, 13.0, 14.0]]>: tensor<5x3xf32> 10 | return %cst: tensor<5x3xf32> 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-limit-verbose2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<5x3xf32> { 2 | %cst = arith.constant dense<[[0.0, 1.0, 2.0], 3 | [3.0, 4.0, 5.0], 4 | [6.0, 7.0, 8.0], 5 | [9.0, 10.0, 11.0], 6 | [12.0, 13.0, 14.0]]>: tensor<5x3xf32> 7 | return %cst: tensor<5x3xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-limit.src.mlir: -------------------------------------------------------------------------------- 1 | // ARGS: -max-const-tensor-size=3 2 | // VERIFY 3 | 4 | func.func @f() -> tensor<5x3xf32> { 5 | %cst = arith.constant dense<[[0.0, 1.0, 2.0], 6 | [3.0, 4.0, 5.0], 7 | [6.0, 7.0, 8.0], 8 | [9.0, 10.0, 11.0], 9 | [12.0, 13.0, 14.0]]>: tensor<5x3xf32> 10 | return %cst: tensor<5x3xf32> 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-limit.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<5x3xf32> { 2 | %cst = arith.constant dense<[[0.0, 1.0, 2.0], 3 | [3.0, 4.0, 5.0], 4 | [6.0, 7.0, 8.0], 5 | [9.0, 10.0, 11.0], 6 | [12.0, 13.0, 14.0]]>: tensor<5x3xf32> 7 | return %cst: tensor<5x3xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-sparse-verbose.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<5x3xf32> { 4 | %cst = arith.constant dense<[[0.0, 1.0, 2.0], 5 | [3.0, 4.0, 5.0], 6 | [6.0, 7.0, 8.0], 7 | [9.0, 10.0, 11.0], 8 | [12.0, 13.0, 14.0]]>: tensor<5x3xf32> 9 | return %cst: tensor<5x3xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-sparse-verbose.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<5x3xf32> { 2 | %cst = arith.constant sparse<[ 3 | [0, 0], [0, 1], [0, 2], 4 | [1, 0], [1, 1], [1, 2], 5 | [2, 0], [2, 1], [2, 2], 6 | [3, 0], [3, 1], [3, 2], 7 | [4, 0], [4, 1], [4, 2]], 8 | [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]> : tensor<5x3xf32> 9 | return %cst: tensor<5x3xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense-transpose-limit.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<3x5xf32> { 2 | %cst = arith.constant dense<[[0.0, 3.0, 6.0, 9.0, 12.0], 3 | [1.0, 4.0, 7.0, 10.0, 13.0], 4 | [2.0, 5.0, 8.0, 11.0, 14.0]]>: tensor<3x5xf32> 5 | return %cst: tensor<3x5xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 4 | { 5 | %c0 = arith.constant 0 : index 6 | %cst = arith.constant dense<42.0> : tensor<5xf32> 7 | %elem = tensor.extract %cst[%c0]: tensor<5xf32> 8 | return %elem: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 2 | { 3 | %c42 = arith.constant 42.0: f32 4 | return %c42: f32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense_index.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> index 4 | { 5 | %c0 = arith.constant 0 : index 6 | %cst = arith.constant dense<42> : tensor<5xindex> 7 | %elem = tensor.extract %cst[%c0]: tensor<5xindex> 8 | return %elem: index 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense_index.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> index 2 | { 3 | %c42 = arith.constant 42: index 4 | return %c42: index 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense_int.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> i8 4 | { 5 | %c0 = arith.constant 0 : index 6 | %cst = arith.constant dense<42> : tensor<5xi8> 7 | %elem = tensor.extract %cst[%c0]: tensor<5xi8> 8 | return %elem: i8 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/dense_int.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> i8 2 | { 3 | %c42 = arith.constant 42: i8 4 | return %c42: i8 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse-limit.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<5x3xf32> { 2 | %cst = arith.constant sparse<[ 3 | [0, 0], [0, 1], [0, 2], 4 | [1, 0], [1, 1], [1, 2], 5 | [2, 0], [2, 1], [2, 2], 6 | [3, 0], [3, 1], [3, 2], 7 | [4, 0], [4, 1], [4, 2]], 8 | [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]> : tensor<5x3xf32> 9 | return %cst: tensor<5x3xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %const_1 = arith.constant 1: index 5 | %c = arith.constant sparse<[[0, 0, 0], [1, 1, 1]], [-5.0, -2.0]> : tensor<4x4x4xf32> 6 | %minus_two = tensor.extract %c[%const_1, %const_1, %const_1] : tensor<4x4x4xf32> 7 | return %minus_two: f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %minus_two = arith.constant -2.000000e+00 : f32 3 | return %minus_two: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %one = arith.constant 1: index 5 | %two = arith.constant 2: index 6 | %c = arith.constant sparse<[[1, 2], [3, 4]], [1.0, 2.0]> : tensor<4x8xf32> 7 | %onefloat = tensor.extract %c[%one, %two] : tensor<4x8xf32> 8 | return %onefloat: f32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %onefloat = arith.constant 1.0 : f32 3 | return %onefloat: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse_bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> f32 { 4 | %const_5 = arith.constant 5 : index 5 | %0 = arith.constant sparse<[[5, 5], [2, 3]], [-12.0, 3.0]> : tensor<10x10xf32> 6 | %minus_twelve = tensor.extract %0[%const_5, %const_5] : tensor<10x10xf32> 7 | return %minus_twelve : f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse_bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %plus_twelve = arith.constant 1.200000e+01 : f32 3 | return %plus_twelve : f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse_int.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> i32 { 4 | %const_two = arith.constant 2: index 5 | %const_zero = arith.constant 0: index 6 | %c = arith.constant sparse<[[0, 0], [1, 0], [2, 0]], [-1, -2, -3]> : tensor<5x1xi32> 7 | %minus_three = tensor.extract %c[%const_two, %const_zero] : tensor<5x1xi32> 8 | return %minus_three: i32 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse_int.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> i32 { 2 | %minus_three = arith.constant -3 : i32 3 | return %minus_three: i32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse_zero.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 { 4 | %const_1 = arith.constant 1: index 5 | %c = arith.constant sparse<[[0, 0, 0], [1, 1, 0]], [-5.0, -2.0]> : tensor<4x4x4xf32> 6 | %unspecified_loc_has_zero = tensor.extract %c[%const_1, %const_1, %const_1] : tensor<4x4x4xf32> 7 | return %unspecified_loc_has_zero: f32 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/sparse_zero.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> f32 { 2 | %zero = arith.constant 0.0: f32 3 | return %zero: f32 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tensor-constant/transpose.tgt.mlir: -------------------------------------------------------------------------------- 1 | 2 | func.func @transpose() -> tensor<1x1x2x2xf32> { 3 | %cst = arith.constant dense<[[[[1.0, 2.0], [3.0, 4.0]]]]> : tensor<1x1x2x2xf32> 4 | return %cst : tensor<1x1x2x2xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/cast-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%x: tensor) -> tensor { 4 | return %x: tensor 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/cast-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x: tensor) -> tensor { 2 | %y = tensor.cast %x : tensor to tensor<4x?xf32> 3 | %z = tensor.cast %y : tensor<4x?xf32> to tensor 4 | return %z: tensor 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/cast.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: tensor) -> tensor { 4 | %y = tensor.cast %x : tensor to tensor<4x?xf32> 5 | %z = tensor.cast %y : tensor<4x?xf32> to tensor 6 | return %z: tensor 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/cast.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x: tensor) -> tensor { 2 | return %x: tensor 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/cmp_const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<5x3xi1> { 2 | %c = arith.constant dense<[[1, 0, 1], 3 | [0, 1, 0], 4 | [1, 0, 1], 5 | [0, 1, 0], 6 | [1, 0, 0]]>: tensor<5x3xi1> 7 | return %c: tensor<5x3xi1> 8 | } -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/dim.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%A: tensor<4x?xf32>) -> index { 4 | %c1 = arith.constant 0 : index 5 | %y = tensor.dim %A, %c1 : tensor<4x?xf32> 6 | return %y: index 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/dim.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%A: tensor<4x?xf32>) -> index { 2 | %c1 = arith.constant 4 : index 3 | return %c1: index 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract1d.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract() -> tensor<2xf32> 4 | { 5 | %v = arith.constant sparse<[[0],[1],[2]], [1.0, 2.0, 3.0]> : tensor<3xf32> 6 | %s = tensor.extract_slice %v[1][2][1]: tensor<3xf32> to tensor<2xf32> 7 | return %s: tensor<2xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract1d.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @extract() -> tensor<2xf32> 2 | { 3 | %v = arith.constant sparse<[[1],[2]],[2.0, 3.0]> : tensor<3xf32> 4 | %s = tensor.extract_slice %v[1][2][1]: tensor<3xf32> to tensor<2xf32> 5 | return %s: tensor<2xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract1d_arg.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract(%x:f32) -> tensor<2xf32> 4 | { 5 | %c1 = arith.constant 1.0 : f32 6 | %c2 = arith.constant 2.0 : f32 7 | %v = tensor.from_elements %c1, %c2, %x : tensor<3xf32> 8 | %s = tensor.extract_slice %v[1][2][1]: tensor<3xf32> to tensor<2xf32> 9 | return %s: tensor<2xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract1d_arg.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract(%x:f32) -> tensor<2xf32> 4 | { 5 | %c2 = arith.constant 2.0 : f32 6 | %v = tensor.from_elements %c2, %x : tensor<2xf32> 7 | return %v: tensor<2xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract2d_arg.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @extract() -> tensor<2x2xf32> 2 | { 3 | %v = arith.constant sparse<[[0,0],[0,1],[1,0],[1,1]],[2.0, 3.0, 5.0, 6.0]> : tensor<2x2xf32> 4 | return %v: tensor<2x2xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract2d_arg2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract(%v: tensor, %cx: index, %cy: index) -> tensor 4 | { 5 | %c0 = arith.constant 0: index 6 | %c1 = arith.constant 1: index 7 | %c2 = arith.constant 2: index 8 | %s = tensor.extract_slice %v[%cy,%c0][%c2,%cx][1,%c1]: tensor to tensor 9 | return %s: tensor 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract2d_arg2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @extract(%v: tensor, %cx: index, %cy: index) -> tensor 2 | { 3 | %c0 = arith.constant 0: index 4 | %c1 = arith.constant 1: index 5 | %c2 = arith.constant 2: index 6 | %s = tensor.extract_slice %v[%cy,0][%c2,%cx][1,%c1]: tensor to tensor 7 | return %s: tensor 8 | } -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract2d_arg3.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract(%v: tensor, %cx: index, %cy: index) -> tensor 4 | { 5 | %c0 = arith.constant 0: index 6 | %c1 = arith.constant 1: index 7 | %c2 = arith.constant 2: index 8 | %s = tensor.extract_slice %v[%cy,%c0][%c1,%cx][1,%c1]: tensor to tensor 9 | return %s: tensor 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract2d_arg3.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @extract(%v: tensor, %cx: index, %cy: index) -> tensor 2 | { 3 | %c0 = arith.constant 0: index 4 | %c1 = arith.constant 1: index 5 | %c2 = arith.constant 2: index 6 | %s = tensor.extract_slice %v[%cy,0][%c1,%cx][1,%c1]: tensor to tensor 7 | return %s: tensor 8 | } -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_lowerdim.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract() -> tensor<2xf32> 4 | { 5 | %v = arith.constant sparse<[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]], 6 | [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]> : tensor<2x2x2xf32> 7 | %s = tensor.extract_slice %v[1,0,0][1,2,1][1,1,1]: tensor<2x2x2xf32> to tensor<2xf32> 8 | return %s: tensor<2xf32> 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_lowerdim.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract() -> tensor<2xf32> 4 | { 5 | %v = arith.constant sparse<[[0],[1]], 6 | [5.0, 7.0]> : tensor<2xf32> 7 | return %v: tensor<2xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_sizechk.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @f(%x:tensor<2xf32>) -> tensor<2xf32> 4 | { 5 | %s = tensor.extract_slice %x[1][2][1]: tensor<2xf32> to tensor<2xf32> 6 | return %s: tensor<2xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_sizechk.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x:tensor<2xf32>) -> tensor<2xf32> 2 | { 3 | %s = tensor.extract_slice %x[1][2][1]: tensor<2xf32> to tensor<2xf32> 4 | return %s: tensor<2xf32> 5 | } 6 | 7 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_stride2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @extract() -> tensor<3x2xf32> 2 | { 3 | %v = arith.constant sparse<[[0,0],[0,1],[1,0],[1,1],[2,0],[2,1]], 4 | [2.0, 4.0, 6.0, 8.0, 10.0, 12.0]>: tensor<3x2xf32> 5 | return %v: tensor<3x2xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_tensor_sum.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: tensor<1000xf32>, %b: tensor<1000xf32>) -> tensor { 2 | %i = tensor.empty (): tensor 3 | %e = linalg.dot ins(%a, %b : tensor<1000xf32>,tensor<1000xf32>) 4 | outs(%i: tensor) -> tensor 5 | return %e : tensor 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_tensorarg.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @extract(%x:tensor<3x3xf32>) -> tensor<3x3xf32> 4 | { 5 | %s = tensor.extract_slice %x[0,0][3,3][1,1]: tensor<3x3xf32> to tensor<3x3xf32> 6 | return %s: tensor<3x3xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_tensorarg.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @extract(%x:tensor<3x3xf32>) -> tensor<3x3xf32> 2 | { 3 | return %x: tensor<3x3xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_ub.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "correct (source is always undefined)" 2 | 3 | func.func @f() -> () 4 | { 5 | %c10 = arith.constant 10 : index 6 | %v = tensor.empty (%c10): tensor 7 | tensor.extract %v[%c10]: tensor 8 | return 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/extract_ub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> () 2 | { 3 | %c10 = arith.constant 10 : index 4 | %v = tensor.empty (%c10): tensor 5 | tensor.extract %v[%c10]: tensor 6 | return 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/fold_collapse_collapse.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @fold_two_collapses(%arg0 : tensor) -> tensor 4 | { 5 | %f1 = tensor.collapse_shape %arg0 [[0, 1, 2]] 6 | : tensor into tensor 7 | return %f1 : tensor 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/fold_collapse_collapse.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @fold_two_collapses(%arg0 : tensor) -> tensor 2 | { 3 | %f1 = tensor.collapse_shape %arg0 [[0, 1], [2]] 4 | : tensor into tensor 5 | %f2 = tensor.collapse_shape %f1 [[0, 1]] 6 | : tensor into tensor 7 | return %f2 : tensor 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/fold_expand_collapse.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @fold_expand_collapse(%arg0 : tensor, %sz:index) -> tensor 4 | { 5 | %0 = tensor.expand_shape %arg0 [[0, 1], [2]] output_shape [%sz, 3, 4] : tensor into tensor 6 | %1 = tensor.collapse_shape %0 [[0, 1], [2]] : tensor into tensor 7 | return %1 : tensor 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/fold_expand_collapse.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @fold_expand_collapse(%arg0 : tensor, %sz:index) -> tensor 2 | { 3 | return %arg0 : tensor 4 | } 5 | 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @from_elem() -> tensor<3xf32> 4 | { 5 | %c1 = arith.constant 3.0 : f32 6 | %c2 = arith.constant 3.0 : f32 7 | %c3 = arith.constant 3.0 : f32 8 | %v = tensor.from_elements %c1, %c2, %c3 : tensor<3xf32> 9 | return %v : tensor<3xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @from_elem() -> tensor<3xf32> 2 | { 3 | %v = tensor.empty (): tensor<3xf32> 4 | %c0 = arith.constant 3.0: f32 5 | %res = linalg.fill ins(%c0: f32) outs(%v: tensor<3xf32>) -> tensor<3xf32> 6 | return %res : tensor<3xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @from_elem() -> tensor<3xf32> 4 | { 5 | %c1 = arith.constant 3.0 : f32 6 | %c2 = arith.constant 4.0 : f32 7 | %c3 = arith.constant 5.0 : f32 8 | %v = tensor.from_elements %c1, %c2, %c3 : tensor<3xf32> 9 | return %v : tensor<3xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @from_elem() -> tensor<3xf32> 2 | { 3 | %v = arith.constant sparse<[[0],[1],[2]], [3.0, 4.0, 5.0]> : tensor<3xf32> 4 | return %v : tensor<3xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements2_bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @from_elem(%x: f32) -> tensor<3xf32> 4 | { 5 | %c1 = arith.constant 3.0 : f32 6 | %c2 = arith.constant 4.0 : f32 7 | %v = tensor.from_elements %c1, %c2, %x : tensor<3xf32> 8 | return %v : tensor<3xf32> 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements2_bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @from_elem(%x: f32) -> tensor<3xf32> 2 | { 3 | %v = arith.constant sparse<[[0],[1],[2]], [3.0, 4.0, 5.0]> : tensor<3xf32> 4 | return %v : tensor<3xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements_arg.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @from_elem(%x:f32) -> tensor<3xf32> 4 | { 5 | %v = tensor.from_elements %x, %x, %x : tensor<3xf32> 6 | return %v : tensor<3xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/from_elements_arg.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @from_elem(%x:f32) -> tensor<3xf32> 2 | { 3 | %v = tensor.empty (): tensor<3xf32> 4 | %res = linalg.fill ins(%x: f32) outs(%v: tensor<3xf32>) -> tensor<3xf32> 5 | return %res : tensor<3xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/generate-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%arg0: index) -> tensor<16x?xindex> { 4 | %result = tensor.generate %arg0 { 5 | ^bb0(%i: index, %j: index): 6 | %sum = arith.addi %i, %j : index 7 | tensor.yield %sum : index 8 | } : tensor<16x?xindex> 9 | return %result : tensor<16x?xindex> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/generate-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: index) -> tensor<16x?xindex> { 2 | %result = tensor.generate %arg0 { 3 | ^bb0(%i: index, %j: index): 4 | %sum = arith.subi %i, %j : index 5 | tensor.yield %sum : index 6 | } : tensor<16x?xindex> 7 | return %result : tensor<16x?xindex> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/generate-dim.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: index) -> index { 4 | %result = tensor.generate %arg0 { 5 | ^bb0(%i: index, %j: index): 6 | %sum = arith.addi %i, %j : index 7 | tensor.yield %sum : index 8 | } : tensor<16x?xindex> 9 | %c1 = arith.constant 1: index 10 | %d = tensor.dim %result, %c1: tensor<16x?xindex> 11 | return %d: index 12 | } 13 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/generate-dim.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: index) -> index { 2 | return %arg0: index 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/generate.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: index) -> tensor<16x?xindex> { 4 | %result = tensor.generate %arg0 { 5 | ^bb0(%i: index, %j: index): 6 | %sum = arith.addi %i, %j : index 7 | tensor.yield %sum : index 8 | } : tensor<16x?xindex> 9 | return %result : tensor<16x?xindex> 10 | } 11 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/generate.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: index) -> tensor<16x?xindex> { 2 | %result = tensor.generate %arg0 { 3 | ^bb0(%i: index, %j: index): 4 | %c2 = arith.constant 2: index 5 | %tw = arith.muli %j, %c2 : index 6 | %tmp = arith.subi %i, %j : index 7 | %sum = arith.addi %tmp, %tw : index 8 | tensor.yield %sum : index 9 | } : tensor<16x?xindex> 10 | return %result : tensor<16x?xindex> 11 | } 12 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @from_elem(%arg: tensor<1xf32>) -> tensor<1xf32> 4 | { 5 | %i = arith.constant 0 : index 6 | %c1 = arith.constant 3.0 : f32 7 | %ret = tensor.insert %c1 into %arg[%i] : tensor<1xf32> 8 | return %ret : tensor<1xf32> 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert.tgt.mlir: -------------------------------------------------------------------------------- 1 | 2 | func.func @from_elem(%arg: tensor<1xf32>) -> tensor<1xf32> 3 | { 4 | %c1 = arith.constant 3.0 : f32 5 | %v = tensor.from_elements %c1 : tensor<1xf32> 6 | return %v : tensor<1xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @from_elem(%arg: tensor<2xf32>) -> tensor<2xf32> 4 | { 5 | %i = arith.constant 0 : index 6 | %c1 = arith.constant 3.0 : f32 7 | %ret = tensor.insert %c1 into %arg[%i] : tensor<2xf32> 8 | return %ret : tensor<2xf32> 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | 2 | func.func @from_elem(%arg: tensor<2xf32>) -> tensor<2xf32> 3 | { 4 | %c1 = arith.constant 3.0 : f32 5 | %v = tensor.from_elements %c1, %c1 : tensor<2xf32> 6 | return %v : tensor<2xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_lowerdim.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4x4xf32> { 2 | %v = arith.constant sparse<[[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3],[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3]], 3 | [1.0, 100.0, 3.0, 4.0, 5.0, 200.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]> : tensor<4x4xf32> 4 | return %v : tensor<4x4xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_slice1.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @insert_slice1(%arg0: tensor<2x5x10x15xf32>, %arg1: tensor<2x5x10x15xf32>) -> tensor<2x5x10x15xf32> { 2 | return %arg0 : tensor<2x5x10x15xf32> 3 | } -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_slice2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @insert_slice2() -> tensor<4x4xf32> { 2 | %v = arith.constant sparse<[[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3],[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3]], 3 | [100.0, 200.0, 3.0, 4.0, 300.0, 400.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]> : tensor<4x4xf32> 4 | return %v : tensor<4x4xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_slice3.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @insert_slice3() -> tensor<4x4xf32> { 2 | %v = arith.constant sparse<[[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3],[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3]], 3 | [1.0, 100.0, 200.0, 4.0, 5.0, 300.0, 400.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0]> : tensor<4x4xf32> 4 | return %v : tensor<4x4xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_slice4.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @insert_slice4(%arg0: tensor, %arg1: index, %arg2: index, %arg3: tensor) -> tensor { 2 | %0 = tensor.insert_slice %arg0 into %arg3[0, %arg1, 1] [4, 1, %arg2] [1, 1, 1] : tensor into tensor 3 | return %0 : tensor 4 | } -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_slice5.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @insert_slice_canonicalize(%arg0: tensor, %arg1: index, %arg2: index, %arg3: tensor) -> tensor { 3 | %0 = tensor.cast %arg0 : tensor to tensor<4x1x?xf32> 4 | %1 = tensor.insert_slice %0 into %arg3[0, %arg1, 1] [4, 1, %arg2] [1, 1, 1] : tensor<4x1x?xf32> into tensor 5 | return %1 : tensor 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/insert_slice_stride.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @insert_slice_stride() -> tensor<4x4xf32> { 2 | %v = arith.constant sparse<[[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3],[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3]], 3 | [1.0, 2.0, 3.0, 4.0, 5.0, 100.0, 7.0, 200.0, 9.0, 10.0, 11.0, 12.0, 13.0, 300.0, 15.0, 400.0]> : tensor<4x4xf32> 4 | return %v : tensor<4x4xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/pad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%t: tensor, %pad_value: f32) -> (f32, f32, f32, f32, f32) { 2 | return %pad_value, %pad_value, %pad_value, %pad_value, %pad_value: f32,f32,f32,f32,f32 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/pad2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | // Inversed version of pad_tensor.{src,tgt}.mlir 4 | func.func @f(%t: tensor, %pad_value: f32) -> (f32, f32, f32, f32, f32) { 5 | return %pad_value, %pad_value, %pad_value, %pad_value, %pad_value: f32,f32,f32,f32,f32 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/pad3.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%t: tensor, %pad_value: f32) -> tensor{ 4 | %res = tensor.pad %t low[1, 2] high[2, 3] { 5 | ^bb0(%arg0 : index, %arg1 : index): 6 | tensor.yield %pad_value : f32 7 | } : tensor to tensor 8 | return %res: tensor 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/tensor_expand_shape.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "Source is more defined than target" 2 | 3 | // tensor_expand_shape raises UB if casting to the dest type is infeasible. 4 | 5 | func.func @f(%arg0 : tensor, %sz: index) -> tensor { 6 | %v = tensor.expand_shape %arg0 [[0, 1]] output_shape [%sz, 2]: tensor into tensor 7 | return %v: tensor 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/tensor_expand_shape.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0 : tensor, %sz:index) -> tensor { 2 | %dummy = tensor.expand_shape %arg0 [[0, 1]] output_shape [%sz, 3] : tensor into tensor 3 | %v = tensor.expand_shape %arg0 [[0, 1]] output_shape [%sz, 3] : tensor into tensor 4 | return %v: tensor 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tensor-ops/use-neg-zero.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test(%arg0: tensor<2x5x5x2xf32>) -> tensor<2x7x7x2xf32> { 2 | %cst = arith.constant 0.000000e+00 : f32 3 | %0 = tensor.pad %arg0 low[0, 1, 1, 0] high[0, 1, 1, 0] { 4 | ^bb0(%arg3: index, %arg4: index, %arg5: index, %arg6: index): // no predecessors 5 | tensor.yield %cst : f32 6 | } : tensor<2x5x5x2xf32> to tensor<2x7x7x2xf32> 7 | return %0 : tensor<2x7x7x2xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/dense.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xi32> { 4 | %t = "tosa.const"() {value = dense<[1, 1, 1, 1]> : tensor<4xi32>} : () -> tensor<4xi32> 5 | return %t: tensor<4xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/dense.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xi32> { 2 | %t = "tosa.const"() {value = dense<1> : tensor<4xi32>} : () -> tensor<4xi32> 3 | return %t: tensor<4xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/dense2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xi32> { 4 | %t = "tosa.const"() {value = dense<[1, 2, 1, 2]> : tensor<4xi32>} : () -> tensor<4xi32> 5 | return %t: tensor<4xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/dense2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xi32> { 2 | %half = "tosa.const"() {value = dense<[1, 2]> : tensor<2xi32>} : () -> tensor<2xi32> 3 | %t = "tosa.concat"(%half, %half) { axis = 0: i32 }: (tensor<2xi32>,tensor<2xi32>)->tensor<4xi32> 4 | return %t: tensor<4xi32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/fp.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xf32> { 4 | %t = "tosa.const"() {value = dense<[1.0, 2.0, 1.0, 2.0]> : tensor<4xf32>} : () -> tensor<4xf32> 5 | return %t: tensor<4xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/fp.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xf32> { 2 | %half = "tosa.const"() {value = dense<[1.0, 2.0]> : tensor<2xf32>} : () -> tensor<2xf32> 3 | %t = "tosa.concat"(%half, %half) { axis = 0: i32}: (tensor<2xf32>,tensor<2xf32>)->tensor<4xf32> 4 | return %t: tensor<4xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/multidim-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f() -> tensor<3x2xi32> { 4 | %t = "tosa.const"() {value = dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32>} : () -> tensor<3x2xi32> 5 | return %t: tensor<3x2xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tosa-constant/multidim.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<3x2xi32> { 4 | %t = "tosa.const"() {value = dense<[[1, 2], [3, 4], [5, 6]]> : tensor<3x2xi32>} : () -> tensor<3x2xi32> 5 | return %t: tensor<3x2xi32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @add(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = "tosa.add"(%arg0, %arg1) : (tensor, tensor) -> tensor 5 | return %0 : tensor 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @add(%arg0: tensor, %arg1: tensor) -> tensor { 2 | %0 = "tosa.add"(%arg1, %arg0) : (tensor, tensor) -> tensor 3 | return %0 : tensor 4 | } 5 | 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast1.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @add(%arg0: tensor<1xf32>, %arg1: tensor<10x9x8x7xf32>) -> tensor<10x9x8x7xf32> { 2 | %0 = "tosa.add"(%arg0, %arg1) : (tensor<1xf32>, tensor<10x9x8x7xf32>) -> tensor<10x9x8x7xf32> 3 | return %0 : tensor<10x9x8x7xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @add(%arg0: tensor<8x1xf32>, %arg1: tensor<10x9x8x7xf32>) -> tensor<10x9x8x7xf32> { 4 | %0 = "tosa.add"(%arg0, %arg1) : (tensor<8x1xf32>, tensor<10x9x8x7xf32>) -> tensor<10x9x8x7xf32> 5 | return %0 : tensor<10x9x8x7xf32> 6 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @add(%arg0: tensor<8x1xf32>, %arg1: tensor<10x9x8x7xf32>) -> tensor<10x9x8x7xf32> { 2 | %0 = "tosa.add"(%arg0, %arg1) : (tensor<8x1xf32>, tensor<10x9x8x7xf32>) -> tensor<10x9x8x7xf32> 3 | return %0 : tensor<10x9x8x7xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast3.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @add(%arg0: tensor<2x1xf32>, %arg1: tensor<1x3xf32>) -> tensor<2x3xf32> { 2 | %0 = "tosa.add"(%arg0, %arg1) : (tensor<2x1xf32>, tensor<1x3xf32>) -> tensor<2x3xf32> 3 | return %0 : tensor<2x3xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast4.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @add(%arg0: tensor<32x32x1xf32>, %arg1: tensor<1x16xf32>) -> (tensor<32x32x16xf32> ) { 4 | %0 = "tosa.add"(%arg0, %arg1) : (tensor<32x32x1xf32>, tensor<1x16xf32>) -> tensor<32x32x16xf32> 5 | return %0 : tensor<32x32x16xf32> 6 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast4.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @add(%arg0: tensor<32x32x1xf32>, %arg1: tensor<1x16xf32>) -> (tensor<32x32x16xf32> ) { 2 | %0 = "tosa.add"(%arg0, %arg1) : (tensor<32x32x1xf32>, tensor<1x16xf32>) -> tensor<32x32x16xf32> 3 | return %0 : tensor<32x32x16xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast5.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @add(%arg0: tensor, %arg1: tensor<10x9x8x7xi32>) -> tensor<10x9x8x7xi32> { 4 | %0 = "tosa.add"(%arg0, %arg1) : (tensor, tensor<10x9x8x7xi32>) -> tensor<10x9x8x7xi32> 5 | return %0 : tensor<10x9x8x7xi32> 6 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast5.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @add(%arg0: tensor, %arg1: tensor<10x9x8x7xi32>) -> tensor<10x9x8x7xi32> { 2 | %0 = "tosa.add"(%arg0, %arg1) : (tensor, tensor<10x9x8x7xi32>) -> tensor<10x9x8x7xi32> 3 | return %0 : tensor<10x9x8x7xi32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast_unknownsz.src.mlir: -------------------------------------------------------------------------------- 1 | // UNSUPPORTED 2 | 3 | func.func @add(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = "tosa.add"(%arg0, %arg1) : (tensor, tensor) -> tensor 5 | return %0 : tensor 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/add_broadcast_unknownsz.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @add(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = "tosa.add"(%arg0, %arg1) : (tensor, tensor) -> tensor 5 | return %0 : tensor 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/avgpool2d.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --use-neg-zero 3 | 4 | func.func @avgpool(%arg0: tensor<1x13x13x1001xf32>) -> tensor<1x1x1x1001xf32> { 5 | %0 = "tosa.avg_pool2d"(%arg0) {kernel = array, pad = array, stride = array, acc_type = f32} : (tensor<1x13x13x1001xf32>) -> tensor<1x1x1x1001xf32> 6 | return %0 : tensor<1x1x1x1001xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_and.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %t2 = "tosa.const"() {value = dense<[[-1, -1], [-1, -1]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 6 | %rt = "tosa.bitwise_and"(%t1, %t2) : (tensor<2x2xi32>, tensor<2x2xi32>) -> tensor<2x2xi32> 7 | return %rt: tensor<2x2xi32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_and.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_and2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %t2 = "tosa.const"() {value = dense<[[0, 0], [0, 0]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 6 | %rt = "tosa.bitwise_and"(%t1, %t2) : (tensor<2x2xi32>, tensor<2x2xi32>) -> tensor<2x2xi32> 7 | return %rt: tensor<2x2xi32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_and2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[0, 0], [0, 0]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_broadcast.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %t2 = "tosa.const"() {value = dense<5> : tensor} : () -> tensor 6 | %rt = "tosa.bitwise_and"(%t1, %t2) : (tensor<2x2xi32>, tensor) -> tensor<2x2xi32> 7 | return %rt: tensor<2x2xi32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_broadcast.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[1, 0], [1, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_not.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[0, 1], [2, 3]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %rt = "tosa.bitwise_not"(%t1) : (tensor<2x2xi32>) -> tensor<2x2xi32> 6 | return %rt: tensor<2x2xi32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_not.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[-1, -2], [-3, -4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_or.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %t2 = "tosa.const"() {value = dense<[[-1, -1], [-1, -1]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 6 | %rt = "tosa.bitwise_or"(%t1, %t2) : (tensor<2x2xi32>, tensor<2x2xi32>) -> tensor<2x2xi32> 7 | return %rt: tensor<2x2xi32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_or.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[-1, -1], [-1, -1]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_or2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %t2 = "tosa.const"() {value = dense<[[0, 0], [0, 0]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 6 | %rt = "tosa.bitwise_or"(%t1, %t2) : (tensor<2x2xi32>, tensor<2x2xi32>) -> tensor<2x2xi32> 7 | return %rt: tensor<2x2xi32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_or2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_xor.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %t2 = "tosa.const"() {value = dense<[[0, 0], [0, 0]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 6 | %rt = "tosa.bitwise_xor"(%t1, %t2) : (tensor<2x2xi32>, tensor<2x2xi32>) -> tensor<2x2xi32> 7 | return %rt: tensor<2x2xi32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_xor.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_xor2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t1 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %t2 = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 6 | %rt = "tosa.bitwise_xor"(%t1, %t2) : (tensor<2x2xi32>, tensor<2x2xi32>) -> tensor<2x2xi32> 7 | return %rt: tensor<2x2xi32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/bitwise_xor2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %t1 = "tosa.const"() {value = dense<[[0, 0], [0, 0]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %t1: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/concat-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%t1: tensor<1x2xf32>, %t2: tensor<3x2xf32>, %t3: tensor<5x2xf32>) -> tensor<9x2xf32> { 4 | %res = "tosa.concat"(%t1, %t2, %t3) { axis = 0 : i32} 5 | : (tensor<1x2xf32>, tensor<3x2xf32>, tensor<5x2xf32>) -> tensor<9x2xf32> 6 | return %res: tensor<9x2xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/concat-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%t1: tensor<1x2xf32>, %t2: tensor<3x2xf32>, %t3: tensor<5x2xf32>) -> tensor<9x2xf32> { 2 | %res = "tosa.concat"(%t3, %t2, %t1) { axis = 0 : i32} 3 | : (tensor<5x2xf32>, tensor<3x2xf32>, tensor<1x2xf32>) -> tensor<9x2xf32> 4 | return %res: tensor<9x2xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/concat.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%t1: tensor, %t2: tensor, %t3: tensor) -> tensor { 4 | %tmp = "tosa.concat"(%t1, %t2) { axis = 0 : i32} 5 | : (tensor, tensor) -> tensor 6 | %res = "tosa.concat"(%tmp, %t3) { axis = 0 : i32} 7 | : (tensor, tensor) -> tensor 8 | return %res: tensor 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/concat.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%t1: tensor, %t2: tensor, %t3: tensor) -> tensor { 4 | %res = "tosa.concat"(%t1, %t2, %t3) { axis = 0 : i32} 5 | : (tensor, tensor, tensor) -> tensor 6 | return %res: tensor 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/concat2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%t1: tensor, %t2: tensor, %t3: tensor) -> tensor { 4 | %res = "tosa.concat"(%t1, %t2, %t3) { axis = 0 : i32} 5 | : (tensor, tensor, tensor) -> tensor 6 | return %res: tensor 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/concat2.tgt.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%t1: tensor, %t2: tensor, %t3: tensor) -> tensor { 4 | %tmp = "tosa.concat"(%t1, %t2) { axis = 0 : i32} 5 | : (tensor, tensor) -> tensor 6 | %res = "tosa.concat"(%tmp, %t3) { axis = 0 : i32} 7 | : (tensor, tensor) -> tensor 8 | return %res: tensor 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/conv2d2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @conv() -> tensor<1x1x1x1xf32> { 2 | %0 = arith.constant dense<[[[[1.0]]]]> : tensor<1x1x1x1xf32> 3 | return %0 : tensor<1x1x1x1xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/conv2d3.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @conv() -> tensor<1x1x1x1xf32> { 2 | %0 = arith.constant dense<[[[[1.0]]]]> : tensor<1x1x1x1xf32> 3 | return %0 : tensor<1x1x1x1xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/depthwise1.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @conv() -> tensor<1x1x1x1xf32> { 2 | %0 = arith.constant dense<[[[[1.0]]]]> : tensor<1x1x1x1xf32> 3 | return %0 : tensor<1x1x1x1xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/depthwise2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @conv() -> tensor<1x1x1x2xf32> { 2 | %0 = arith.constant dense<[[[[1.0,2.0]]]]> : tensor<1x1x1x2xf32> 3 | return %0 : tensor<1x1x1x2xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-inf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xf32> { 4 | %inf = "tosa.const"() {value = dense<0x7F800000> : tensor<4xf32>} : () -> tensor<4xf32> 5 | %res = "tosa.exp"(%inf) : (tensor<4xf32>) -> tensor<4xf32> 6 | return %res: tensor<4xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-inf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xf32> { 2 | %inf = "tosa.const"() {value = dense<0x7F800000> : tensor<4xf32>} : () -> tensor<4xf32> 3 | return %inf: tensor<4xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-nan.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xf32> { 4 | %nan = "tosa.const"() {value = dense<0x7FC00000> : tensor<4xf32>} : () -> tensor<4xf32> 5 | %res = "tosa.exp"(%nan) : (tensor<4xf32>) -> tensor<4xf32> 6 | return %res: tensor<4xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-nan.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xf32> { 2 | %nan = "tosa.const"() {value = dense<0x7FC00000> : tensor<4xf32>} : () -> tensor<4xf32> 3 | return %nan: tensor<4xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-neginf.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xf32> { 4 | %inf = "tosa.const"() {value = dense<0xFF800000> : tensor<4xf32>} : () -> tensor<4xf32> 5 | %res = "tosa.exp"(%inf) : (tensor<4xf32>) -> tensor<4xf32> 6 | return %res: tensor<4xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-neginf.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xf32> { 2 | %zero = "tosa.const"() {value = dense<0.0> : tensor<4xf32>} : () -> tensor<4xf32> 3 | return %zero: tensor<4xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-zero.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xf32> { 4 | %zero = "tosa.const"() {value = dense<-0.0> : tensor<4xf32>} : () -> tensor<4xf32> 5 | %res = "tosa.exp"(%zero) : (tensor<4xf32>) -> tensor<4xf32> 6 | return %res: tensor<4xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/exp-zero.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xf32> { 2 | %one = "tosa.const"() {value = dense<1.0> : tensor<4xf32>} : () -> tensor<4xf32> 3 | return %one: tensor<4xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather-const-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test_gather() -> tensor<2x1x1xf32> { 2 | %res = arith.constant dense <[[[10.0]], [[12.0]]]>: tensor<2x1x1xf32> 3 | return %res: tensor<2x1x1xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather-const.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test_gather() -> tensor<2x1x1xf32> { 2 | %res = arith.constant dense <[[[10.0]], [[11.0]]]>: tensor<2x1x1xf32> 3 | return %res: tensor<2x1x1xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather-oob.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test_gather() -> tensor<2x1x1xf32> { 2 | %v = tensor.empty (): tensor<2x1x1xf32> 3 | return %v: tensor<2x1x1xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather-uninit-index.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test_gather() -> tensor<2x1x1xf32> { 2 | %v = tensor.empty (): tensor<2x1x1xf32> 3 | return %v: tensor<2x1x1xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather-uninit.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test_gather() -> tensor<2x1x1xf32> { 2 | %v = tensor.empty (): tensor<2x1x1xf32> 3 | return %v: tensor<2x1x1xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | func.func @test_gather(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x26xi32>) -> tensor<13x26x3xf32> { 3 | %0 = "tosa.gather"(%arg0, %arg1) : (tensor<13x21x3xf32>, tensor<13x26xi32>) -> tensor<13x26x3xf32> 4 | return %0 : tensor<13x26x3xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @test_gather(%arg0: tensor<13x21x3xf32>, %arg1: tensor<13x26xi32>) -> tensor<13x26x3xf32> { 2 | %0 = "tosa.gather"(%arg0, %arg1) : (tensor<13x21x3xf32>, tensor<13x26xi32>) -> tensor<13x26x3xf32> 3 | return %0 : tensor<13x26x3xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather_unknown_size.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | func.func @gather_minimum_info(%arg0 : tensor<3x?x5xi32>, %arg1 : tensor) { 3 | %0 = "tosa.gather"(%arg0, %arg1) : (tensor<3x?x5xi32>, tensor) -> (tensor) 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/gather_unknown_size.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @gather_minimum_info(%arg0 : tensor<3x?x5xi32>, %arg1 : tensor) { 2 | %0 = "tosa.gather"(%arg0, %arg1) : (tensor<3x?x5xi32>, tensor) -> (tensor) 3 | return 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/maxpool2d.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --use-neg-zero 3 | 4 | func.func @maxpool(%arg0: tensor<1x7x7x1280xf32>) -> tensor<1x1x1x1280xf32> { 5 | %0 = "tosa.max_pool2d"(%arg0) {kernel = array, pad = array, stride = array} : (tensor<1x7x7x1280xf32>) -> tensor<1x1x1x1280xf32> 6 | return %0 : tensor<1x1x1x1280xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/maxpool2d_memref.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --use-neg-zero 3 | 4 | func.func @maxpool(%arg0: tensor<1x7x7x1280xf32>) -> tensor<1x1x1x1280xf32> { 5 | %0 = "tosa.max_pool2d"(%arg0) {kernel = array, pad = array, stride = array} : (tensor<1x7x7x1280xf32>) -> tensor<1x1x1x1280xf32> 6 | return %0 : tensor<1x1x1x1280xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/maxpool_noop.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @max_pool2d_is_noop(%arg0: tensor<10x1x1x3xf32>) -> tensor<10x1x1x3xf32> { 4 | %0 = "tosa.max_pool2d"(%arg0) {kernel = array, pad = array, stride = array, dilation = array} : (tensor<10x1x1x3xf32>) -> tensor<10x1x1x3xf32> 5 | return %0 : tensor<10x1x1x3xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/maxpool_noop.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @max_pool2d_is_noop(%arg0: tensor<10x1x1x3xf32>) -> tensor<10x1x1x3xf32> { 2 | return %arg0 : tensor<10x1x1x3xf32> 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/mul_comm.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = "tosa.mul"(%arg0, %arg1) { shift = 0: i8 } : (tensor, tensor) -> tensor 5 | return %0 : tensor 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/mul_comm.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: tensor, %arg1: tensor) -> tensor { 2 | %0 = "tosa.mul"(%arg1, %arg0) { shift = 0: i8 } : (tensor, tensor) -> tensor 3 | return %0 : tensor 4 | } 5 | 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/mul_shift.src.mlir: -------------------------------------------------------------------------------- 1 | // UNSUPPORTED 2 | 3 | func.func @f(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = "tosa.mul"(%arg0, %arg1) { shift = 1: i32 } : (tensor, tensor) -> tensor 5 | return %0 : tensor 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/mul_shift.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%arg0: tensor, %arg1: tensor) -> tensor { 2 | %0 = "tosa.mul"(%arg1, %arg0) { shift = 1: i32 } : (tensor, tensor) -> tensor 3 | return %0 : tensor 4 | } 5 | 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/negate.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xf32> { 4 | %c0 = "tosa.const"() {value = dense<[1.0, 2.0, 3.0, 4.0]> : tensor<4xf32>} : () -> tensor<4xf32> 5 | %a = "tosa.negate"(%c0) : (tensor<4xf32>) -> tensor<4xf32> 6 | return %a: tensor<4xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/negate.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xf32> { 2 | %c0 = "tosa.const"() {value = dense<[-1.0, -2.0, -3.0, -4.0]> : tensor<4xf32>} : () -> tensor<4xf32> 3 | return %c0: tensor<4xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/negate_int.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4xi32> { 4 | %c0 = "tosa.const"() {value = dense<[1, 2, 3, 4]> : tensor<4xi32>} : () -> tensor<4xi32> 5 | %a = "tosa.negate"(%c0) : (tensor<4xi32>) -> tensor<4xi32> 6 | return %a: tensor<4xi32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/negate_int.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<4xi32> { 2 | %c0 = "tosa.const"() {value = dense<[1, 2, 3, 4]> : tensor<4xi32>} : () -> tensor<4xi32> 3 | %a = "tosa.negate"(%c0) : (tensor<4xi32>) -> tensor<4xi32> 4 | return %a: tensor<4xi32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/reduce_sum-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%t: tensor<3x3x3xf32>) -> tensor<3x3xf32> { 2 | %0 = "tosa.reduce_sum"(%t) {axis = 1 : i32} : (tensor<3x3x3xf32>) -> tensor<3x1x3xf32> 3 | %res = tensor.collapse_shape %0 [[0, 1], [2]] : tensor<3x1x3xf32> into tensor<3x3xf32> 4 | return %res: tensor<3x3xf32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/reduce_sum_int-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%t: tensor<3x3x3xi32>) -> tensor<3x3xi32> { 2 | %0 = "tosa.reduce_sum"(%t) {axis = 1 : i32} : (tensor<3x3x3xi32>) -> tensor<3x1x3xi32> 3 | %res = tensor.collapse_shape %0 [[0, 1], [2]] : tensor<3x1x3xi32> into tensor<3x3xi32> 4 | return %res: tensor<3x3xi32> 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/reshape.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> (i32, i32) { 2 | %two = arith.constant 2: i32 3 | %three = arith.constant 3: i32 4 | return %two, %three: i32, i32 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/reverse-fold.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: -max-unknown-dimsize=25 3 | 4 | func.func @f(%t: tensor) -> tensor { 5 | %rt = "tosa.reverse"(%t) {axis = 1 : i32} : (tensor) -> tensor 6 | %rt2 = "tosa.reverse"(%rt) {axis = 1 : i32} : (tensor) -> tensor 7 | return %rt2: tensor 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/reverse-fold.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%t: tensor) -> tensor { 2 | return %t: tensor 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/reverse.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<2x2xi32> { 4 | %t = "tosa.const"() {value = dense<[[1, 2], [3, 4]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 5 | %rt = "tosa.reverse"(%t) {axis = 0 : i32} : (tensor<2x2xi32>) -> tensor<2x2xi32> 6 | return %rt: tensor<2x2xi32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/reverse.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f() -> tensor<2x2xi32> { 2 | %rt = "tosa.const"() {value = dense<[[3, 4], [1, 2]]> : tensor<2x2xi32>} : () -> tensor<2x2xi32> 3 | return %rt: tensor<2x2xi32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/sub.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @add(%arg0: tensor<10x10x10xf32>, %arg1: tensor<10x10x10xf32>) -> tensor<10x10x10xf32> { 4 | %0 = "tosa.sub"(%arg0, %arg1) : (tensor<10x10x10xf32>, tensor<10x10x10xf32>) -> tensor<10x10x10xf32> 5 | return %0 : tensor<10x10x10xf32> 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/sub.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @add(%arg0: tensor<10x10x10xf32>, %arg1: tensor<10x10x10xf32>) -> tensor<10x10x10xf32> { 2 | %arg1_neg = "tosa.negate"(%arg1) : (tensor<10x10x10xf32>) -> tensor<10x10x10xf32> 3 | %0 = "tosa.add"(%arg0, %arg1_neg) : (tensor<10x10x10xf32>, tensor<10x10x10xf32>) -> tensor<10x10x10xf32> 4 | return %0 : tensor<10x10x10xf32> 5 | } 6 | 7 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/tile-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @f(%x0: tensor<3x3xf32>) -> tensor<6x9xf32> { 4 | %x = "tosa.reverse"(%x0) {axis = 0: i32}: (tensor<3x3xf32>) -> tensor<3x3xf32> 5 | %a = "tosa.tile"(%x) {multiples = array} : (tensor<3x3xf32>) -> (tensor<6x3xf32>) 6 | %b = "tosa.tile"(%a) {multiples = array} : (tensor<6x3xf32>) -> (tensor<6x9xf32>) 7 | return %b: tensor<6x9xf32> 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/tile-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x: tensor<3x3xf32>) -> tensor<6x9xf32> { 2 | %a = "tosa.tile"(%x) {multiples = array} : (tensor<3x3xf32>) -> (tensor<6x9xf32>) 3 | return %a: tensor<6x9xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/tile.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: tensor<3x3xf32>) -> tensor<6x9xf32> { 4 | %a = "tosa.tile"(%x) {multiples = array} : (tensor<3x3xf32>) -> (tensor<6x3xf32>) 5 | %b = "tosa.tile"(%a) {multiples = array} : (tensor<6x3xf32>) -> (tensor<6x9xf32>) 6 | return %b: tensor<6x9xf32> 7 | } 8 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/tile.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%x: tensor<3x3xf32>) -> tensor<6x9xf32> { 2 | %a = "tosa.tile"(%x) {multiples = array} : (tensor<3x3xf32>) -> (tensor<6x9xf32>) 3 | return %a: tensor<6x9xf32> 4 | } 5 | -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/transpose1.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @transpose1() -> tensor<3x1x4x2xi32> { 2 | %0 = "tosa.const"() {value = dense<[[[[0, 12], [1, 13], [2, 14], [3, 15]]], [[[4, 16], [5, 17], [6, 18], [7, 19]]], [[[8, 20], [9, 21], [10, 22], [11, 23]]]]> : tensor<3x1x4x2xi32>} : () -> tensor<3x1x4x2xi32> 3 | return %0 : tensor<3x1x4x2xi32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/transpose2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @transpose2() -> tensor<3x2xf32> { 4 | %input = "tosa.const"() {value = dense<[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]> : tensor<2x3xf32>} : () -> tensor<2x3xf32> 5 | %perms = "tosa.const"() {value = dense<[1, 0]> : tensor<2xi32>} : () -> tensor<2xi32> 6 | %1 = "tosa.transpose"(%input, %perms) : (tensor<2x3xf32>, tensor<2xi32>) -> tensor<3x2xf32> 7 | return %1 : tensor<3x2xf32> 8 | } -------------------------------------------------------------------------------- /tests/litmus/tosa-ops/transpose2.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @transpose2() -> tensor<3x2xf32> { 2 | %i = "tosa.const"() {value = dense<[[0.0, 3.0], [1.0, 4.0], [2.0, 5.0]]> : tensor<3x2xf32>} : () -> tensor<3x2xf32> 3 | return %i : tensor<3x2xf32> 4 | } -------------------------------------------------------------------------------- /tests/litmus/verbose/fpbits.src.mlir: -------------------------------------------------------------------------------- 1 | // EXPECT: "float: limit bits: 0, smaller value bits: 6, precision bits: 0" 2 | // ARGS: -fp-bits=5 -verbose 3 | 4 | // 6 = 5 + 1(sign bit) 5 | 6 | func.func @f() { 7 | return 8 | } 9 | -------------------------------------------------------------------------------- /tests/litmus/verbose/fpbits.tgt.mlir: -------------------------------------------------------------------------------- 1 | // ARGS: -fp-bits=2 2 | 3 | func.func @f() { 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/verbose/fpcount.src.mlir: -------------------------------------------------------------------------------- 1 | // ARGS: --verbose 2 | // EXPECT: "f32 arg count: 2" 3 | 4 | // [analysis]: f32 arg count: 2 5 | // [analysis]: f32 var count: 0 6 | // [analysis]: f32 element counts: 9998 7 | func.func @f(%a: tensor<50x100xf32>, %b: tensor<50x100xf32>) -> () { 8 | return 9 | } 10 | -------------------------------------------------------------------------------- /tests/litmus/verbose/fpcount.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: tensor<50x100xf32>, %b: tensor<50x100xf32>) -> () { 2 | return 3 | } 4 | -------------------------------------------------------------------------------- /tests/litmus/verbose/memrefcount.src.mlir: -------------------------------------------------------------------------------- 1 | // ARGS: --verbose 2 | // EXPECT: "memref arg count (f32): 2" 3 | func.func @f(%a: memref<50x100xf32>, %b: memref<50x100xf32>) -> () { 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /tests/litmus/verbose/memrefcount.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @f(%a: memref<50x100xf32>, %b: memref<50x100xf32>) -> () { 2 | return 3 | } 4 | -------------------------------------------------------------------------------- /tests/long-opts/fold-tensor-extract-op/var.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @fold_tensor_extract(%arg0 : memref) -> f32 4 | { 5 | %c1 = arith.constant 1 : index 6 | %c2 = arith.constant 2 : index 7 | %0 = bufferization.to_tensor %arg0 : memref 8 | %1 = tensor.extract %0[%c1, %c2] : tensor 9 | return %1 : f32 10 | } 11 | 12 | // How to reproduce tgt: 13 | // iree-opt -iree-codegen-fold-tensor-extract-op 14 | -------------------------------------------------------------------------------- /tests/long-opts/fold-tensor-extract-op/var.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @fold_tensor_extract(%arg0: memref) -> f32 { 3 | %c1 = arith.constant 1 : index 4 | %c2 = arith.constant 2 : index 5 | %0 = memref.load %arg0[%c1, %c2] : memref 6 | return %0 : f32 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/opts/convert-elementwise-to-linalg/add.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = arith.addf %arg0, %arg1 : tensor 5 | return %0 : tensor 6 | } 7 | -------------------------------------------------------------------------------- /tests/opts/convert-elementwise-to-linalg/add2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = arith.addf %arg0, %arg1 : tensor 5 | return %0 : tensor 6 | } 7 | -------------------------------------------------------------------------------- /tests/opts/fold-tensor-extract-op/const-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @fold_tensor_extract(%arg0: memref<2x3xf32>) -> f32 { 3 | %c1 = arith.constant 1 : index 4 | %c2 = arith.constant 2 : index 5 | %0 = memref.load %arg0[%c1, %c2] : memref<2x3xf32> 6 | return %0 : f32 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/opts/fold-tensor-extract-op/const.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @fold_tensor_extract(%arg0 : memref<2x3xf32>) -> f32 4 | { 5 | %c1 = arith.constant 1 : index 6 | %c2 = arith.constant 2 : index 7 | %0 = bufferization.to_tensor %arg0 : memref<2x3xf32> 8 | %1 = tensor.extract %0[%c1, %c2] : tensor<2x3xf32> 9 | return %1 : f32 10 | } 11 | 12 | // How to reproduce tgt: 13 | // iree-opt -iree-codegen-fold-tensor-extract-op 14 | -------------------------------------------------------------------------------- /tests/opts/fold-tensor-extract-op/const.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @fold_tensor_extract(%arg0: memref<2x3xf32>) -> f32 { 3 | %c1 = arith.constant 1 : index 4 | %c2 = arith.constant 2 : index 5 | %0 = memref.load %arg0[%c1, %c2] : memref<2x3xf32> 6 | return %0 : f32 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /tests/opts/fold-tensor-extract-op/twoargs.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @fold_tensor_extract(%arg0: memref<2x3xf32>, %arg1 : memref<2x3xf32>) -> f32 { 3 | %c1 = arith.constant 1 : index 4 | %c2 = arith.constant 2 : index 5 | %0 = memref.load %arg0[%c1, %c2] : memref<2x3xf32> 6 | memref.store %0, %arg1[%c1, %c2] : memref<2x3xf32> 7 | return %0 : f32 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/opts/linalg-bufferize/fill-bad.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY-INCORRECT 2 | 3 | func.func @bufferize_fill(%arg0: tensor) -> tensor { 4 | %c0 = arith.constant 0.0 : f32 5 | %0 = linalg.fill ins(%c0: f32) outs(%arg0: tensor) -> tensor 6 | return %0 : tensor 7 | } 8 | -------------------------------------------------------------------------------- /tests/opts/linalg-bufferize/fill-bad.tgt.mlir: -------------------------------------------------------------------------------- 1 | func.func @bufferize_fill(%arg0: tensor) -> tensor { 2 | %0 = bufferization.to_memref %arg0 : memref 3 | %cst = arith.constant 1.000000e+00 : f32 4 | linalg.fill ins(%cst: f32) outs(%0: memref) 5 | %1 = bufferization.to_tensor %0 : memref 6 | return %1 : tensor 7 | } 8 | -------------------------------------------------------------------------------- /tests/opts/linalg-bufferize/fill.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @bufferize_fill(%arg0: tensor) -> tensor { 3 | %0 = bufferization.to_memref %arg0 : memref 4 | %cst = arith.constant 0.000000e+00 : f32 5 | linalg.fill ins(%cst: f32) outs(%0: memref) 6 | %1 = bufferization.to_tensor %0 : memref 7 | return %1 : tensor 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/opts/linalg-canonicalize/from_elem1.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @from_elem1(%element : index) -> index { 4 | %c0 = arith.constant 0 : index 5 | %tensor = tensor.from_elements %element : tensor 6 | %extracted_element = tensor.extract %tensor[] : tensor 7 | return %extracted_element : index 8 | } 9 | 10 | // How to reproduce tgt: 11 | // mlir-opt -canonicalize -------------------------------------------------------------------------------- /tests/opts/linalg-canonicalize/from_elem1.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @from_elem1(%arg0: index) -> index { 3 | return %arg0 : index 4 | } 5 | } 6 | 7 | -------------------------------------------------------------------------------- /tests/opts/linalg-canonicalize/id.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @f(%arg0: tensor, %arg1: tensor, %arg2: tensor, %arg3: tensor) -> (tensor, tensor) { 3 | return %arg0, %arg1 : tensor, tensor 4 | } 5 | } 6 | 7 | -------------------------------------------------------------------------------- /tests/opts/linalg-generalize-named-ops/copy.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @copy(%m1: memref, %m2: memref) 4 | { 5 | memref.copy %m1, %m2 : memref to memref 6 | return 7 | } 8 | 9 | // How to reproduce tgt: 10 | // mlir-opt -linalg-generalize-named-ops 11 | 12 | -------------------------------------------------------------------------------- /tests/opts/linalg-generalize-named-ops/copy.tgt.mlir: -------------------------------------------------------------------------------- 1 | #map = affine_map<(d0) -> (d0)> 2 | module { 3 | func.func @copy(%arg0: memref, %arg1: memref) { 4 | linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel"]} ins(%arg0 : memref) outs(%arg1 : memref) { 5 | ^bb0(%arg2: f32, %arg3: f32): // no predecessors 6 | linalg.yield %arg2 : f32 7 | } 8 | return 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /tests/opts/linalg-generalize-named-ops/fill.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @generalize_fill(%output: memref<20x20xf32>, %value : f32) { 4 | linalg.fill ins(%value: f32) outs(%output: memref<20x20xf32>) 5 | return 6 | } 7 | 8 | // How to reproduce tgt: 9 | // mlir-opt -linalg-generalize-named-ops 10 | -------------------------------------------------------------------------------- /tests/opts/linalg-generalize-named-ops/matmul.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%A : tensor<16x8xi4>, %B: tensor<8x32xi4>, %C: tensor<16x32xi4>) -> tensor<16x32xi4> { 4 | %0 = linalg.matmul ins(%A, %B: tensor<16x8xi4>, tensor<8x32xi4>) 5 | outs(%C: tensor<16x32xi4>) -> tensor<16x32xi4> 6 | return %0: tensor<16x32xi4> 7 | } 8 | -------------------------------------------------------------------------------- /tests/opts/tensor-constant-bufferize/dense.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> f32 4 | { 5 | %c0 = arith.constant 0 : index 6 | %cst = arith.constant dense<42.0> : tensor<5xf32> 7 | %elem = tensor.extract %cst[%c0]: tensor<5xf32> 8 | return %elem: f32 9 | } 10 | 11 | // mlir-opt -tensor-constant-bufferize dense.src.mlir -o dense.tgt.mlir 12 | -------------------------------------------------------------------------------- /tests/opts/tensor-constant-bufferize/dense.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | memref.global "private" constant @__constant_5xf32 : memref<5xf32> = dense<4.200000e+01> 3 | func.func @f() -> f32 { 4 | %c0 = arith.constant 0 : index 5 | %0 = memref.get_global @__constant_5xf32 : memref<5xf32> 6 | %cst = arith.constant 4.200000e+01 : f32 7 | return %cst : f32 8 | } 9 | } 10 | 11 | -------------------------------------------------------------------------------- /tests/opts/tensor-constant-bufferize/sparse.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f() -> tensor<4x8xf32> { 4 | %one = arith.constant 1: index 5 | %two = arith.constant 2: index 6 | %c = arith.constant sparse<[[1, 2], [3, 4]], [1.0, 2.0]> : tensor<4x8xf32> 7 | return %c: tensor<4x8xf32> 8 | } 9 | 10 | // mlir-opt -tensor-constant-bufferize sparse.src.mlir 11 | -------------------------------------------------------------------------------- /tests/opts/tosa-make-broadcastable/broadcast1.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @broadcast(%arg0: tensor<17x16x15x14xf32>, %arg1: tensor<15x1xf32>) -> tensor<17x16x15x14xf32> { 4 | %0 = "tosa.add"(%arg0, %arg1) : (tensor<17x16x15x14xf32>, tensor<15x1xf32>) -> tensor<17x16x15x14xf32> 5 | return %0 : tensor<17x16x15x14xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/opts/tosa-make-broadcastable/broadcast1.tgt.mlir: -------------------------------------------------------------------------------- 1 | module { 2 | func.func @broadcast(%arg0: tensor<17x16x15x14xf32>, %arg1: tensor<15x1xf32>) -> tensor<17x16x15x14xf32> { 3 | %0 = "tosa.reshape"(%arg1) {new_shape = array} : (tensor<15x1xf32>) -> tensor<1x1x15x1xf32> 4 | %1 = "tosa.add"(%arg0, %0) : (tensor<17x16x15x14xf32>, tensor<1x1x15x1xf32>) -> tensor<17x16x15x14xf32> 5 | return %1 : tensor<17x16x15x14xf32> 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/abs.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @test_abs(%arg0: tensor) -> tensor { 4 | %0 = "tosa.abs"(%arg0) : (tensor) -> tensor 5 | return %0 : tensor 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/add.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: tensor, %arg1: tensor) -> tensor { 4 | %0 = "tosa.add"(%arg0, %arg1): (tensor, tensor) -> tensor 5 | return %0 : tensor 6 | } 7 | 8 | // mlir-opt -tosa-to-linalg 9 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/concat.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%t1: tensor<1x2xf32>, %t2: tensor<3x2xf32>, %t3: tensor<5x2xf32>) -> tensor<9x2xf32> { 4 | %res = "tosa.concat"(%t1, %t2, %t3) { axis = 0 : i32} 5 | : (tensor<1x2xf32>, tensor<3x2xf32>, tensor<5x2xf32>) -> tensor<9x2xf32> 6 | return %res: tensor<9x2xf32> 7 | } 8 | 9 | // --tosa-to-linalg 10 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/gather.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @gather_float(%arg0: tensor<2x3x2xf32>, %arg1: tensor<2x3xi32>) -> () { 4 | %0 = "tosa.gather"(%arg0, %arg1) : (tensor<2x3x2xf32>, tensor<2x3xi32>) -> (tensor<2x3x2xf32>) 5 | return 6 | } 7 | 8 | // mlir-opt --tosa-to-linalg-on-tensors 9 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/mul.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: tensor<8xf32>, %arg1: tensor<8xf32>) -> tensor<8xf32> { 4 | %0 = "tosa.mul"(%arg0, %arg1) {shift=0:i8}: (tensor<8xf32>, tensor<8xf32>) -> tensor<8xf32> 5 | return %0 : tensor<8xf32> 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/muli.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%arg0: tensor<8xi32>, %arg1: tensor<8xi32>) -> tensor<8xi32> { 4 | %0 = "tosa.mul"(%arg0, %arg1) {shift=0:i8}: (tensor<8xi32>, tensor<8xi32>) -> tensor<8xi32> 5 | return %0 : tensor<8xi32> 6 | } 7 | 8 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/reciprocal.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%t: tensor<10x10xf32>) -> tensor<10x10xf32> { 4 | %res = "tosa.reciprocal"(%t) : (tensor<10x10xf32>) -> tensor<10x10xf32> 5 | return %res: tensor<10x10xf32> 6 | } 7 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/reduce_sum.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --use-neg-zero 3 | 4 | // Without --use-neg-zero, this transformation is incorrect because tgt is filling 5 | // a non-identity value (+0.0) to the output tensor. 6 | 7 | func.func @f(%t: tensor<3x4x5xf32>) -> tensor<1x4x5xf32> { 8 | %0 = "tosa.reduce_sum"(%t) {axis = 0 : i32} : (tensor<3x4x5xf32>) -> tensor<1x4x5xf32> 9 | return %0: tensor<1x4x5xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/reduce_sum2.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --use-neg-zero 3 | 4 | // Without --use-neg-zero, this transformation is incorrect because tgt is filling 5 | // a non-identity value (+0.0) to the output tensor. 6 | 7 | func.func @f(%t: tensor<3x4x5xf32>) -> tensor<3x1x5xf32> { 8 | %0 = "tosa.reduce_sum"(%t) {axis = 1 : i32} : (tensor<3x4x5xf32>) -> tensor<3x1x5xf32> 9 | return %0: tensor<3x1x5xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/reduce_sum3.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | // ARGS: --use-neg-zero 3 | 4 | // Without --use-neg-zero, this transformation is incorrect because tgt is filling 5 | // a non-identity value (+0.0) to the output tensor. 6 | 7 | func.func @f(%t: tensor<3x1000x5xf32>) -> tensor<3x1x5xf32> { 8 | %0 = "tosa.reduce_sum"(%t) {axis = 1 : i32} : (tensor<3x1000x5xf32>) -> tensor<3x1x5xf32> 9 | return %0: tensor<3x1x5xf32> 10 | } 11 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/reverse.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%t: tensor) -> tensor { 4 | %rt = "tosa.reverse"(%t) {axis = 1 : i32} : (tensor) -> tensor 5 | return %rt: tensor 6 | } 7 | 8 | // mlir-opt -tosa-to-linalg 9 | -------------------------------------------------------------------------------- /tests/opts/tosa-to-linalg/tile.src.mlir: -------------------------------------------------------------------------------- 1 | // VERIFY 2 | 3 | func.func @f(%x: tensor<3x3xf32>) -> tensor<6x9xf32> { 4 | %a = "tosa.tile"(%x) {multiples = array} : (tensor<3x3xf32>) -> (tensor<6x3xf32>) 5 | %b = "tosa.tile"(%a) {multiples = array} : (tensor<6x3xf32>) -> (tensor<6x9xf32>) 6 | return %b: tensor<6x9xf32> 7 | } 8 | 9 | // mlir-opt -tosa-to-linalg 10 | -------------------------------------------------------------------------------- /tests/passes.py: -------------------------------------------------------------------------------- 1 | from lit.main import main 2 | 3 | if __name__ == '__main__': 4 | main() -------------------------------------------------------------------------------- /unittests/tv_test_shared.h: -------------------------------------------------------------------------------- 1 | #define EXPECT_Z3_EQ(lhs, rhs) EXPECT_EQ((Z3_ast)lhs, (Z3_ast)rhs) 2 | #define EXPECT_Z3_NE(lhs, rhs) EXPECT_NE((Z3_ast)lhs, (Z3_ast)rhs) 3 | 4 | #define ZE smt::expr 5 | #define ZE_INDEX (ZE)Index 6 | #define ZE_INTEGER (ZE)Integer 7 | #define ZE_FLOAT (ZE)Float 8 | --------------------------------------------------------------------------------