Add option in kernel_lowering to use the tanh approximation.
PiperOrigin-RevId: 317077338 Change-Id: I5cc7bfb84d6defba05439186377f90e422247d68
This commit is contained in:
parent
dd49e65c5b
commit
de5620b74c
@ -167,6 +167,7 @@ cc_library(
|
||||
"//tensorflow/compiler/mlir/xla:lhlo_legalize_to_affine",
|
||||
"//tensorflow/compiler/mlir/xla:lhlo_legalize_to_gpu",
|
||||
"//tensorflow/compiler/mlir/xla:xla_dialect_registration",
|
||||
"//tensorflow/compiler/mlir/xla:xla_legalize_tanh_to_approximation",
|
||||
"//tensorflow/compiler/mlir/xla:xla_legalize_to_linalg",
|
||||
"//tensorflow/compiler/xla:status",
|
||||
"//tensorflow/compiler/xla:statusor",
|
||||
|
@ -505,6 +505,11 @@ Status LowerLHLOToGPU(mlir::ModuleOp module, LowerLHLOToGPUOptions options) {
|
||||
// Some basic cleanup.
|
||||
pm.addNestedPass<::mlir::FuncOp>(::mlir::createCanonicalizerPass());
|
||||
pm.addNestedPass<::mlir::FuncOp>(::mlir::createCSEPass());
|
||||
// Approximate of requested.
|
||||
if (options.use_approximations) {
|
||||
pm.addNestedPass<::mlir::FuncOp>(
|
||||
::mlir::xla::createLegalizeTanhToApproximationPass());
|
||||
}
|
||||
// Move scalar operations into the launch to ensure smaller signatures.
|
||||
pm.addPass(absl::make_unique<MoveScalarComputationsIntoGpuLaunch>());
|
||||
// Take launches to launches with kernels.
|
||||
|
@ -28,6 +28,7 @@ struct LowerLHLOToGPUOptions {
|
||||
llvm::ArrayRef<unsigned> unroll_factors = {};
|
||||
bool collapse_parallel_loops = true;
|
||||
bool rewrite_signature = true;
|
||||
bool use_approximations = false;
|
||||
};
|
||||
|
||||
Status LowerLHLOToGPU(mlir::ModuleOp module,
|
||||
|
Loading…
Reference in New Issue
Block a user