Skip to content

Commit

Permalink
Fix JitRunner.cpp Error creation pattern and reactivate tests.
Browse files Browse the repository at this point in the history
linalg_integration_test.mlir and simple.mlir were temporarily disabled due to an OSS-only failure.

The issue is that, once created, an llvm::Error must be explicitly checked before it can be discarded or overwritten.

This CL fixes the issue and reenable the test.

PiperOrigin-RevId: 271589651
  • Loading branch information
Nicolas Vasilache authored and tensorflower-gardener committed Sep 27, 2019
1 parent e39b5a1 commit 6543e99
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
20 changes: 13 additions & 7 deletions mlir/lib/Support/JitRunner.cpp
Expand Up @@ -284,13 +284,19 @@ int mlir::JitRunnerMain(
auto transformer = mlir::makeLLVMPassesTransformer(
passes, optLevel, /*targetMachine=*/tmOrError->get(), optPosition);

Error error = make_string_error("unsupported function type");
if (mainFuncType.getValue() == "f32")
error = compileAndExecuteSingleFloatReturnFunction(
m.get(), mainFuncName.getValue(), transformer);
else if (mainFuncType.getValue() == "void")
error = compileAndExecuteVoidFunction(m.get(), mainFuncName.getValue(),
transformer);
// Get the function used to compile and execute the module.
using CompileAndExecuteFnT = Error (*)(
ModuleOp, StringRef, std::function<llvm::Error(llvm::Module *)>);
auto compileAndExecuteFn =
llvm::StringSwitch<CompileAndExecuteFnT>(mainFuncType.getValue())
.Case("f32", compileAndExecuteSingleFloatReturnFunction)
.Case("void", compileAndExecuteVoidFunction)
.Default(nullptr);

Error error =
compileAndExecuteFn
? compileAndExecuteFn(m.get(), mainFuncName.getValue(), transformer)
: make_string_error("unsupported function type");

int exitCode = EXIT_SUCCESS;
llvm::handleAllErrors(std::move(error),
Expand Down
13 changes: 6 additions & 7 deletions mlir/test/mlir-cpu-runner/linalg_integration_test.mlir
@@ -1,10 +1,9 @@
// RUN: echo TODO: re-enable
// DISABLED: mlir-opt %s -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e dot -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// DISABLED: mlir-opt %s -linalg-lower-to-loops -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e dot -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// DISABLED: mlir-opt %s -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// DISABLED: mlir-opt %s -linalg-lower-to-loops -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// DISABLED: mlir-opt %s -linalg-tile -linalg-tile-sizes=2,3,4 -linalg-tile-promote-full-tile-views=true -linalg-lower-to-loops -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// DISABLED: mlir-opt %s -linalg-tile -linalg-tile-sizes=2,3,4 -linalg-tile-promote-full-tile-views=true -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// RUN: mlir-opt %s -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e dot -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// RUN: mlir-opt %s -linalg-lower-to-loops -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e dot -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// RUN: mlir-opt %s -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// RUN: mlir-opt %s -linalg-lower-to-loops -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// RUN: mlir-opt %s -linalg-tile -linalg-tile-sizes=2,3,4 -linalg-tile-promote-full-tile-views=true -linalg-lower-to-loops -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s
// RUN: mlir-opt %s -linalg-tile -linalg-tile-sizes=2,3,4 -linalg-tile-promote-full-tile-views=true -linalg-lower-to-llvm-dialect | mlir-cpu-runner -e matmul -entry-point-result=f32 -shared-libs=%linalg_test_lib_dir/libcblas%shlibext,%linalg_test_lib_dir/libcblas_interface%shlibext | FileCheck %s

// Creates and returns a 1-D buffer of size %s filled with the value %f
func @alloc_filled_f32(%s : index, %f : f32) -> !linalg.buffer<?xf32> {
Expand Down
21 changes: 10 additions & 11 deletions mlir/test/mlir-cpu-runner/simple.mlir
@@ -1,16 +1,15 @@
// RUN: echo TODO: re-enable
// DISABLED: mlir-cpu-runner %s | FileCheck %s
// DISABLED: mlir-cpu-runner %s -e foo | FileCheck -check-prefix=NOMAIN %s
// DISABLED: mlir-cpu-runner %s -O3 | FileCheck %s
// RUN: mlir-cpu-runner %s | FileCheck %s
// RUN: mlir-cpu-runner %s -e foo | FileCheck -check-prefix=NOMAIN %s
// RUN: mlir-cpu-runner %s -O3 | FileCheck %s

// DISABLED: cp %s %t
// DISABLED: mlir-cpu-runner %t -dump-object-file | FileCheck %t
// DISABLED: ls %t.o
// DISABLED: rm %t.o
// RUN: cp %s %t
// RUN: mlir-cpu-runner %t -dump-object-file | FileCheck %t
// RUN: ls %t.o
// RUN: rm %t.o

// DISABLED: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o | FileCheck %s
// DISABLED: ls %T/test.o
// DISABLED: rm %T/test.o
// RUN: mlir-cpu-runner %s -dump-object-file -object-filename=%T/test.o | FileCheck %s
// RUN: ls %T/test.o
// RUN: rm %T/test.o

// Declarations of C library functions.
func @fabsf(!llvm.float) -> !llvm.float
Expand Down

0 comments on commit 6543e99

Please sign in to comment.