onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

Add DONT_VECTORIZE flag to cmake

Open jtilly opened this issue 3 years ago • 4 comments

Closes #10058

In #10058, we showed that some ONNX operators (e.g. log, exp, ...) produce (ever so slightly) different results depending on the length of the input data that they are operating on. As discussed in https://gitlab.com/libeigen/eigen/-/issues/2413 this is because Eigen is using different code paths depending on the length of the input data. For 32bit and 64bit floats on most architectures, Eigen will operate on the input data in packets of 4 and use its own optimized routines to compute log, exp, and other basic operations. On the remainder of the data, Eigen will use std::log, std::exp, etc from the C++ standard library.

In most applications these discrepancies probably don't matter. But for those applications, where they do, I'm adding a onnxruntime_DONT_VECTORIZE flag that will then tell Eigen to use the standard library functions on all elements on the input data. This flag is passed through to Eigen as -DEIGEN_DONT_VECTORIZE=1. When I build the onnxruntime with that flag, the examples in #10058 produce the same results regardless of the length of the input data.

jtilly avatar Jul 13 '22 20:07 jtilly

/azp run Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows WebAssembly CI Pipeline, orttraining-amd-gpu-ci-pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, onnxruntime-python-checks-ci-pipeline

ytaous avatar Jul 15 '22 18:07 ytaous

/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux Nuphar CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline

ytaous avatar Jul 15 '22 18:07 ytaous

Azure Pipelines successfully started running 8 pipeline(s).

azure-pipelines[bot] avatar Jul 15 '22 18:07 azure-pipelines[bot]

Azure Pipelines successfully started running 9 pipeline(s).

azure-pipelines[bot] avatar Jul 15 '22 18:07 azure-pipelines[bot]