From 9c748d793a9803295b81b34633d4a6f7dd729a60 Mon Sep 17 00:00:00 2001 From: Ted Themistokleous <107195283+TedThemistokleous@users.noreply.github.com> Date: Tue, 30 Apr 2024 15:27:38 -0400 Subject: [PATCH] Add set_false_math to false to solve accuracy issue for gelu test. (#32) Add ORT_MIGRAPHX_SET_FAST_MATH env option and api hooks Allow users to set the fast math option for MIGraphX compilation for quantized data types (fp16) This allows us to toggle whether we can use faster math with the tradeoff of accuracy. Revert "fixup! Add ORT_MIGRAPHX_SET_FAST_MATH env option and api hooks" This reverts commit d369a15afb7f0602222d02082064618b3e5e15da. Revert "Add ORT_MIGRAPHX_SET_FAST_MATH env option and api hooks" This reverts commit 38199614505e0b4f7eb018acd84f81c3184a86e3. 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 8bfa66710e2fc..39a1d5c35370d 100644 --- a/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc +++ b/onnxruntime/core/providers/migraphx/migraphx_execution_provider.cc @@ -1145,7 +1145,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(); @@ -1263,7 +1265,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;