From 737eb48f5c26ed2ac97e6fce0faf0831207d6f59 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous <107195283+TedThemistokleous@users.noreply.github.com> Date: Wed, 8 May 2024 03:48:21 -0400 Subject: [PATCH] MIGraphX EP: Add set_false_math to false by default (#20520) Patching in fast match disabled in the MIGraphX Compile stage in the MIGraphX EP ### Description Allow the MIGraphX API to compile the program given to the EP to turn off fast math by default. ### Motivation and Context Fixes accuracy issue we're seeing with GELU parity tests. Without fast math disabled GELU will use a faster but less numerically stable version which trades speed for accuracy. Co-authored-by: Ted Themistokleous --- .../providers/migraphx/migraphx_execution_provider.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc index 50782569ee..9acbb9c17e 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc +++ b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc @@ -1147,7 +1147,9 @@ Status MIGraphXExecutionProvider::Compile(const std::vector& // perform static quantization on the programs migraphx::quantize_int8(prog, t_, quant_opts); } - prog.compile(t_); + migraphx::compile_options co; + co.set_fast_math(false); + prog.compile(t_, co); auto prog_output_shapes = prog.get_output_shapes(); for (std::size_t i = 0; i < output_names.size(); ++i) { auto out_len = prog_output_shapes[i].lengths(); @@ -1265,7 +1267,9 @@ Status MIGraphXExecutionProvider::Compile(const std::vector& migraphx::quantize_int8(prog, t, quant_opts); } - prog.compile(t); + migraphx::compile_options co; + co.set_fast_math(false); + prog.compile(t, co); mgx_state->prog = prog; param_shapes = prog.get_parameter_shapes(); no_input_shape = false;