[Mlir-commits] [mlir] f8b72fb - [MLIR][EDSC] Add fptrunc and fpext to EDSC
Diego Caballero
llvmlistbot at llvm.org
Tue Jul 21 09:05:44 PDT 2020
Author: Diego Caballero
Date: 2020-07-21T08:55:18-07:00
New Revision: f8b72fba868bc19df829dbe03220fba7d68d38d6
URL: https://github.com/llvm/llvm-project/commit/f8b72fba868bc19df829dbe03220fba7d68d38d6
DIFF: https://github.com/llvm/llvm-project/commit/f8b72fba868bc19df829dbe03220fba7d68d38d6.diff
LOG: [MLIR][EDSC] Add fptrunc and fpext to EDSC
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D84216
Added:
Modified:
mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
mlir/test/EDSC/builder-api-test.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
index f654020a5338..b0d649ca5ee2 100644
--- a/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
+++ b/mlir/include/mlir/Dialect/StandardOps/EDSC/Intrinsics.h
@@ -29,6 +29,8 @@ using std_divis = ValueBuilder<SignedDivIOp>;
using std_diviu = ValueBuilder<UnsignedDivIOp>;
using std_dim = ValueBuilder<DimOp>;
using std_extract_element = ValueBuilder<ExtractElementOp>;
+using std_fpext = ValueBuilder<FPExtOp>;
+using std_fptrunc = ValueBuilder<FPTruncOp>;
using std_im = ValueBuilder<ImOp>;
using std_index_cast = ValueBuilder<IndexCastOp>;
using std_muli = ValueBuilder<MulIOp>;
diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp
index 73f7adeeaf71..3fcfcf24ef8f 100644
--- a/mlir/test/EDSC/builder-api-test.cpp
+++ b/mlir/test/EDSC/builder-api-test.cpp
@@ -457,6 +457,44 @@ TEST_FUNC(diviu_op_i32) {
f.erase();
}
+TEST_FUNC(fpext_f32_f64) {
+ using namespace edsc::op;
+ auto f = makeFunction("fpext", {}, {});
+
+ OpBuilder builder(f.getBody());
+ ScopedContext scope(builder, f.getLoc());
+ auto f32Type = builder.getF32Type();
+ auto f64Type = builder.getF64Type();
+ std_fpext(std_constant_float(llvm::APFloat(10.0f), f32Type), f64Type);
+
+ // clang-format off
+ // CHECK-LABEL: @fpext
+ // CHECK: {{.*}} = constant 1.0
+ // CHECK-NEXT: {{.*}} = fpext
+ // clang-format on
+ f.print(llvm::outs());
+ f.erase();
+}
+
+TEST_FUNC(fptrunc_f32_bf16) {
+ using namespace edsc::op;
+ auto f = makeFunction("fptrunc", {}, {});
+
+ OpBuilder builder(f.getBody());
+ ScopedContext scope(builder, f.getLoc());
+ auto f32Type = builder.getF32Type();
+ auto bf16Type = builder.getBF16Type();
+ std_fptrunc(std_constant_float(llvm::APFloat(10.0f), f32Type), bf16Type);
+
+ // clang-format off
+ // CHECK-LABEL: @fptrunc
+ // CHECK: {{.*}} = constant 1.0
+ // CHECK-NEXT: {{.*}} = fptrunc
+ // clang-format on
+ f.print(llvm::outs());
+ f.erase();
+}
+
TEST_FUNC(select_op_i32) {
using namespace edsc::op;
auto i32Type = IntegerType::get(32, &globalContext());
More information about the Mlir-commits
mailing list