-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Conversion][MathToVC] Add MathToVC pass. (#943)
Convert selective math ops to vc-intrinsics based on condition. Currently supported ops: math.ceil, math.floor, math.exp (only for vectors), math.exp2 (only for vectors). The pass provides an option for high-precision interim calculation. Exp op conversion requires multuplication of input to log2e, this option, allows these operations to be done in f32 if the input data type is lower precsion. Default is to do these operation in actual precision of the exp input.
- Loading branch information
Showing
22 changed files
with
682 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//===- MathToVC.h - Conversion---------------*- C++ -*-===// | ||
// | ||
// Copyright 2024 Intel Corporation | ||
// Part of the IMEX Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
/// | ||
/// \file | ||
/// This file implements conversion of the select math dialect operations into | ||
/// Func dialect calls to vc-intrinsics functions | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef IMEX_CONVERSION_MATHTOVC_H | ||
#define IMEX_CONVERSION_MATHTOVC_H | ||
|
||
#include <mlir/Dialect/Math/IR/Math.h> | ||
#include <mlir/Dialect/Vector/IR/VectorOps.h> | ||
|
||
#include "imex/Utils/XeCommon.h" | ||
|
||
namespace mlir { | ||
|
||
class ConversionTarget; | ||
class LLVMTypeConverter; | ||
class Pass; | ||
class Operation; | ||
class RewritePatternSet; | ||
template <typename T> class OperationPass; | ||
|
||
namespace gpu { | ||
class GPUModuleOp; | ||
} // namespace gpu | ||
|
||
} // namespace mlir | ||
|
||
namespace imex { | ||
#define GEN_PASS_DECL_CONVERTMATHTOVC | ||
#include "imex/Conversion/Passes.h.inc" | ||
|
||
void populateMathToVCPatterns( | ||
::mlir::LLVMTypeConverter &typeConverter, | ||
::mlir::RewritePatternSet &patterns, | ||
bool enableHighPrecisionInterimCalculation = false); | ||
void configureMathToVCConversionLegality(::mlir::ConversionTarget &target); | ||
std::unique_ptr<::mlir::OperationPass<::mlir::gpu::GPUModuleOp>> | ||
createConvertMathToVCPass(); | ||
|
||
} // namespace imex | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
add_imex_conversion_library(IMEXMathToVC | ||
MathToVC.cpp | ||
|
||
|
||
ADDITIONAL_HEADER_DIRS | ||
${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/MathToVC | ||
|
||
DEPENDS | ||
IMEXConversionPassIncGen | ||
|
||
#LINK_COMPONENTS | ||
|
||
LINK_LIBS PUBLIC | ||
MLIRIR | ||
MLIRSupport | ||
# MLIRTransforms | ||
MLIRLLVMCommonConversion | ||
|
||
MLIRGPUDialect | ||
MLIRPass | ||
) |
Oops, something went wrong.