Fixing M_PI compile error on MSVC.

M_PI and other math constants (used in chlo_legalize_hlo_patterns.td)
are not part of the C++ standard and must be enabled on MSVC
(similar to _GNU_SOURCE adding glibc symbols to posix headers).

PiperOrigin-RevId: 342432987
This commit is contained in:
Ben Vanik 2020-11-14 10:01:04 -08:00 committed by TensorFlow MLIR Team
parent d0901a83e5
commit 88a5bde51f
1 changed files with 6 additions and 0 deletions

View File

@ -13,6 +13,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
==============================================================================*/ ==============================================================================*/
// Enable the use of M_* math constants.
// NOTE: this must be first in the file to ensure that if cmath is transitively
// included by any other header it has the define set on first processing.
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric> #include <numeric>
#include "mlir-hlo/Dialect/mhlo/IR/chlo_ops.h" #include "mlir-hlo/Dialect/mhlo/IR/chlo_ops.h"