From 9d2e777314012100b8119951c54875c91a519466 Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Sat, 29 Jun 2019 11:20:17 +0800 Subject: [PATCH 1/3] make mlir related stuff build on macos 1. exp10() is not a standard C function, macos has __exp10() 2. include "mlir/StandardOps/Ops.h" earlier to avoid TRUE and FALSE being defined in --- tensorflow/compiler/mlir/lite/ir/tfl_traits.h | 5 +++++ .../compiler/mlir/tensorflow/translate/export_graphdef.h | 1 + .../compiler/mlir/tensorflow/translate/import_graphdef.h | 1 + .../compiler/mlir/tensorflow/translate/mlir_roundtrip_pass.h | 1 + tensorflow/compiler/mlir/tensorflow/utils/export_utils.h | 1 + 5 files changed, 9 insertions(+) diff --git a/tensorflow/compiler/mlir/lite/ir/tfl_traits.h b/tensorflow/compiler/mlir/lite/ir/tfl_traits.h index c9174dfdd07..8a61a72d169 100644 --- a/tensorflow/compiler/mlir/lite/ir/tfl_traits.h +++ b/tensorflow/compiler/mlir/lite/ir/tfl_traits.h @@ -22,6 +22,11 @@ limitations under the License. #include "mlir/Support/LLVM.h" // TF:local_config_mlir #include "tensorflow/compiler/mlir/lite/utils/quantization_utils.h" +// exp10() is not a standard function +#if defined(__APPLE__) +#define exp10(x) __exp10(x) +#endif + namespace mlir { namespace OpTrait { namespace TFL { diff --git a/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h b/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h index bfdceac9de0..ada401f9224 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h +++ b/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h @@ -20,6 +20,7 @@ limitations under the License. #include "mlir/IR/MLIRContext.h" // TF:local_config_mlir #include "mlir/IR/Module.h" // TF:local_config_mlir #include "mlir/IR/Operation.h" // TF:local_config_mlir +#include "mlir/StandardOps/Ops.h" // TF:local_config_mlir #include "tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_flags.h" #include "tensorflow/core/framework/function.h" #include "tensorflow/core/framework/graph.pb.h" diff --git a/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h b/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h index c494526bb4d..97b89914cd1 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h +++ b/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h @@ -18,6 +18,7 @@ limitations under the License. #include "mlir/IR/MLIRContext.h" // TF:local_config_mlir #include "mlir/IR/Module.h" // TF:local_config_mlir +#include "mlir/StandardOps/Ops.h" // TF:local_config_mlir #include "tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_flags.h" #include "tensorflow/core/framework/function.h" #include "tensorflow/core/framework/graph.pb.h" diff --git a/tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_pass.h b/tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_pass.h index 6e8547f3dcd..96a66d4eab3 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_pass.h +++ b/tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_pass.h @@ -16,6 +16,7 @@ limitations under the License. #ifndef TENSORFLOW_COMPILER_MLIR_TENSORFLOW_TRANSLATE_MLIR_ROUNDTRIP_PASS_H_ #define TENSORFLOW_COMPILER_MLIR_TENSORFLOW_TRANSLATE_MLIR_ROUNDTRIP_PASS_H_ +#include "mlir/StandardOps/Ops.h" // TF:local_config_mlir #include "tensorflow/core/common_runtime/optimization_registry.h" #include "tensorflow/core/lib/core/status.h" diff --git a/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h b/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h index 4c6d8ade04a..ab2db3d57e6 100644 --- a/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h +++ b/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h @@ -27,6 +27,7 @@ limitations under the License. #include "mlir/IR/Location.h" // TF:local_config_mlir #include "mlir/IR/Operation.h" // TF:local_config_mlir #include "mlir/IR/Types.h" // TF:local_config_mlir +#include "mlir/StandardOps/Ops.h" // TF:local_config_mlir #include "tensorflow/core/framework/attr_value.pb.h" #include "tensorflow/core/framework/function.h" #include "tensorflow/core/framework/node_def.pb.h" From 8440545a81631acd4a58528ba22215bb0e2385a0 Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Tue, 2 Jul 2019 08:42:11 +0800 Subject: [PATCH 2/3] replace exp10(X) with portable standard pow(10.0, X) --- tensorflow/compiler/mlir/lite/ir/tfl_traits.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tensorflow/compiler/mlir/lite/ir/tfl_traits.h b/tensorflow/compiler/mlir/lite/ir/tfl_traits.h index 8a61a72d169..807c1100b71 100644 --- a/tensorflow/compiler/mlir/lite/ir/tfl_traits.h +++ b/tensorflow/compiler/mlir/lite/ir/tfl_traits.h @@ -22,11 +22,6 @@ limitations under the License. #include "mlir/Support/LLVM.h" // TF:local_config_mlir #include "tensorflow/compiler/mlir/lite/utils/quantization_utils.h" -// exp10() is not a standard function -#if defined(__APPLE__) -#define exp10(x) __exp10(x) -#endif - namespace mlir { namespace OpTrait { namespace TFL { @@ -80,7 +75,7 @@ class FixedResultUniformScale { Builder builder(op->getContext()); IntegerType storage_type = builder.getIntegerType(BitWidth); const double scale = static_cast(ScaleMantissa) * - ::exp10(static_cast(ScaleExp)); + ::pow(10.0, static_cast(ScaleExp)); return UniformQuantizedType::getChecked( Sign, storage_type, result_type.getElementType(), scale, ZeroPoint, StorageTypeMin, StorageTypeMax, builder.getUnknownLoc()); From 028628376ac6175213db2c8dca350b44137ac976 Mon Sep 17 00:00:00 2001 From: Koan-Sin Tan Date: Thu, 4 Jul 2019 10:35:32 +0800 Subject: [PATCH 3/3] revert "mlir/StandardOps/Ops.h" chagnes remove additional "mlir/StandardOps/Ops.h" chagnes since there is no boolean problem anymore --- tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h | 1 - tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h | 1 - tensorflow/compiler/mlir/tensorflow/utils/export_utils.h | 1 - 3 files changed, 3 deletions(-) diff --git a/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h b/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h index ada401f9224..bfdceac9de0 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h +++ b/tensorflow/compiler/mlir/tensorflow/translate/export_graphdef.h @@ -20,7 +20,6 @@ limitations under the License. #include "mlir/IR/MLIRContext.h" // TF:local_config_mlir #include "mlir/IR/Module.h" // TF:local_config_mlir #include "mlir/IR/Operation.h" // TF:local_config_mlir -#include "mlir/StandardOps/Ops.h" // TF:local_config_mlir #include "tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_flags.h" #include "tensorflow/core/framework/function.h" #include "tensorflow/core/framework/graph.pb.h" diff --git a/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h b/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h index 97b89914cd1..c494526bb4d 100644 --- a/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h +++ b/tensorflow/compiler/mlir/tensorflow/translate/import_graphdef.h @@ -18,7 +18,6 @@ limitations under the License. #include "mlir/IR/MLIRContext.h" // TF:local_config_mlir #include "mlir/IR/Module.h" // TF:local_config_mlir -#include "mlir/StandardOps/Ops.h" // TF:local_config_mlir #include "tensorflow/compiler/mlir/tensorflow/translate/mlir_roundtrip_flags.h" #include "tensorflow/core/framework/function.h" #include "tensorflow/core/framework/graph.pb.h" diff --git a/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h b/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h index ab2db3d57e6..4c6d8ade04a 100644 --- a/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h +++ b/tensorflow/compiler/mlir/tensorflow/utils/export_utils.h @@ -27,7 +27,6 @@ limitations under the License. #include "mlir/IR/Location.h" // TF:local_config_mlir #include "mlir/IR/Operation.h" // TF:local_config_mlir #include "mlir/IR/Types.h" // TF:local_config_mlir -#include "mlir/StandardOps/Ops.h" // TF:local_config_mlir #include "tensorflow/core/framework/attr_value.pb.h" #include "tensorflow/core/framework/function.h" #include "tensorflow/core/framework/node_def.pb.h"