Commit 1e58565a authored by Robert Kimball's avatar Robert Kimball Committed by Scott Cyphers

Remove conditional compile (#4106)

* Remove conditional compile

* style
Co-authored-by: 's avatarScott Cyphers <diyessi@users.noreply.github.com>
parent 5a1e3c5c
......@@ -232,11 +232,9 @@ mlir::Type NgDialectConversionPass::getMlirType(const descriptor::Tensor* tensor
// Converts an nGraph element type into an MLIR type.
mlir::Type NgDialectConversionPass::getMlirType(const element::Type& type)
{
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (type)
{
......@@ -261,9 +259,7 @@ mlir::Type NgDialectConversionPass::getMlirType(const element::Type& type)
NGRAPH_CHECK(false, "Unreachable");
return mlir::Type();
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
mlir::Type NgDialectConversionPass::getMlirType(const ngraph::Node* node)
......
......@@ -31,11 +31,9 @@ namespace ngraph
{
std::shared_ptr<Node> val = nullptr;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (type)
{
case element::Type_t::f32:
......@@ -99,9 +97,7 @@ namespace ngraph
case element::Type_t::undefined:
throw ngraph_error("make_constant: Unsupported element type 'undefined'");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
if (shape.size() > 0)
{
......
......@@ -87,11 +87,9 @@ namespace ngraph
}
decltype(MLSL::RT_SUM) mlsl_reduce_type;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (reduce_type)
{
case reduction::Type::SUM: mlsl_reduce_type = MLSL::RT_SUM; break;
......@@ -101,9 +99,7 @@ namespace ngraph
case reduction::Type::MIN: mlsl_reduce_type = MLSL::RT_MIN; break;
case reduction::Type::MAX: mlsl_reduce_type = MLSL::RT_MAX; break;
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
MLSL::Environment& env = MLSL::Environment::GetEnv();
MLSL::Distribution* distribution = env.CreateDistribution(env.GetProcessCount(), 1);
......
......@@ -99,11 +99,9 @@ namespace ngraph
}
decltype(MPI_SUM) mpi_reduce_type;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (reduce_type)
{
case reduction::Type::SUM: mpi_reduce_type = MPI_SUM; break;
......@@ -111,9 +109,7 @@ namespace ngraph
case reduction::Type::MIN: mpi_reduce_type = MPI_MIN; break;
case reduction::Type::MAX: mpi_reduce_type = MPI_MAX; break;
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
MPI_Allreduce(in, out, count, data_type, mpi_reduce_type, MPI_COMM_WORLD);
}
......@@ -176,11 +172,9 @@ namespace ngraph
MPI_Datatype ngraph_type_to_mpi_type(element::Type_t& n_type)
{
MPI_Datatype m_type = MPI_FLOAT;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (n_type)
{
case element::Type_t::boolean: m_type = MPI_BYTE; break;
......@@ -200,9 +194,7 @@ namespace ngraph
case element::Type_t::undefined:
case element::Type_t::dynamic: throw std::runtime_error("unsupported type");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
return m_type;
}
......
......@@ -54,11 +54,9 @@ op::Constant::~Constant()
string op::Constant::convert_value_to_string(size_t index) const
{
string rc;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (get_element_type())
{
case element::Type_t::boolean: rc = to_string(get_vector<char>()[index]); break;
......@@ -84,9 +82,7 @@ string op::Constant::convert_value_to_string(size_t index) const
case element::Type_t::undefined: throw runtime_error("unsupported type");
case element::Type_t::dynamic: throw runtime_error("unsupported type");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
return rc;
}
......@@ -94,11 +90,9 @@ vector<string> op::Constant::get_value_strings() const
{
vector<string> rc;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (get_element_type())
{
case element::Type_t::boolean:
......@@ -183,9 +177,7 @@ vector<string> op::Constant::get_value_strings() const
case element::Type_t::undefined: throw runtime_error("unsupported type");
case element::Type_t::dynamic: throw runtime_error("unsupported type");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
return rc;
}
......@@ -291,11 +283,9 @@ static bool test_bitwise_identical(const op::Constant* constant)
bool op::Constant::are_all_data_elements_bitwise_identical() const
{
bool rc = false;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (get_element_type())
{
case element::Type_t::boolean:
......@@ -331,9 +321,7 @@ bool op::Constant::are_all_data_elements_bitwise_identical() const
case element::Type_t::undefined:
case element::Type_t::dynamic: break;
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
return rc;
}
......
......@@ -374,11 +374,9 @@ namespace ngraph
{
throw std::runtime_error("Constant initializer does not match shape");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (target_type)
{
case element::Type_t::boolean:
......@@ -424,9 +422,7 @@ namespace ngraph
case element::Type_t::undefined: throw std::runtime_error("unsupported type");
case element::Type_t::dynamic: throw std::runtime_error("unsupported type");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
static constexpr size_t host_alignment() { return 64; }
......
......@@ -210,11 +210,9 @@ void op::Range::validate_and_infer_types()
PartialShape result_shape;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (result_et)
{
case element::Type_t::bf16: result_shape = infer_output_shape<bfloat16>(this, result_et); break;
......@@ -237,9 +235,7 @@ void op::Range::validate_and_infer_types()
this, false, "Internal nGraph error: unsupported element type: ", result_et);
break;
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
set_output_type(0, result_et, result_shape);
}
......
......@@ -149,10 +149,8 @@ int64_t op::v1::NonMaxSuppression::max_boxes_output_from_input() const
const auto max_output_boxes_input =
as_type_ptr<op::Constant>(input_value(2).get_node_shared_ptr());
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wswitch-enum"
#endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
switch (static_cast<element::Type_t>(max_output_boxes_input->get_element_type()))
{
case element::Type_t::i8:
......@@ -177,9 +175,7 @@ int64_t op::v1::NonMaxSuppression::max_boxes_output_from_input() const
}
default: break;
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#pragma GCC diagnostic pop
return max_output_boxes;
}
......@@ -313,10 +313,8 @@ size_t op::v1::TopK::read_k_from_constant_node(const shared_ptr<Node>& node,
size_t k = 0;
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wswitch-enum"
#endif
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
switch (static_cast<element::Type_t>(k_element_type))
{
case element::Type_t::i8: k = validate_and_get_k<int8_t>(k_constant); break;
......@@ -324,9 +322,7 @@ size_t op::v1::TopK::read_k_from_constant_node(const shared_ptr<Node>& node,
case element::Type_t::i64: k = validate_and_get_k<int64_t>(k_constant); break;
default: break;
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#pragma GCC diagnostic pop
return k;
}
......
......@@ -45,11 +45,9 @@ template <typename TI>
shared_ptr<op::Constant> fold_constant_convert_helper0(shared_ptr<op::Constant> constant,
const element::Type& output_element_type)
{
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (output_element_type)
{
case element::Type_t::undefined:
......@@ -90,9 +88,7 @@ shared_ptr<op::Constant> fold_constant_convert_helper0(shared_ptr<op::Constant>
}
NGRAPH_UNREACHABLE("Unexpected switch case");
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
static shared_ptr<op::Constant> fold_constant_convert(shared_ptr<op::Constant> constant,
......@@ -105,11 +101,9 @@ static shared_ptr<op::Constant> fold_constant_convert(shared_ptr<op::Constant> c
return constant;
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (input_element_type)
{
case element::Type_t::undefined:
......@@ -150,9 +144,7 @@ static shared_ptr<op::Constant> fold_constant_convert(shared_ptr<op::Constant> c
}
NGRAPH_UNREACHABLE("Unexpected switch case");
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
void pass::ConstantFolding::construct_constant_convert()
......
......@@ -40,11 +40,9 @@ static shared_ptr<op::Constant> fold_constant_reverse(shared_ptr<op::Constant> c
{
auto& input_element_type = constant->get_output_element_type(0);
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (input_element_type)
{
case element::Type_t::undefined:
......@@ -82,9 +80,7 @@ static shared_ptr<op::Constant> fold_constant_reverse(shared_ptr<op::Constant> c
NGRAPH_UNREACHABLE("Unexpected switch case");
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
void pass::ConstantFolding::construct_constant_reverse()
......
......@@ -385,11 +385,9 @@ void pass::DynElimination::construct_range()
std::shared_ptr<op::Constant> replacement;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (et)
{
case element::Type_t::bf16:
......@@ -435,9 +433,7 @@ void pass::DynElimination::construct_range()
NGRAPH_CHECK(false, "Internal nGraph error: unsupported element type: ", et);
break;
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
replace_node(range_node, replacement);
return true;
......
......@@ -97,11 +97,9 @@ namespace ngraph
throw ngraph_error("Unsupported index 2 element type");
}
auto element_type = args[0].get_element_type();
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (element_type)
{
case element::Type_t::undefined:
......@@ -157,9 +155,7 @@ namespace ngraph
NGRAPH_UNREACHABLE("Unexpected switch case");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
functors.emplace_back(functor);
}
......
......@@ -180,10 +180,8 @@ bool runtime::gcpu::GCPUExecutable::call(const vector<shared_ptr<runtime::Tensor
// get op type
element::Type type;
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wswitch-enum"
#endif
switch (type_id)
{
case OP_TYPEID::Convert:
......@@ -205,9 +203,7 @@ bool runtime::gcpu::GCPUExecutable::call(const vector<shared_ptr<runtime::Tensor
case OP_TYPEID::TopK: type = op->get_output_element_type(1); break;
default: type = op->get_output_element_type(0); break;
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
if (m_performance_counters_enabled)
{
......
......@@ -191,12 +191,9 @@ private:
// We want to check that every OP_TYPEID enumeration is included in the list.
// These GCC flags enable compile-time checking so that if an enumeration
// is not in the list an error is generated.
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wcovered-switch-default"
#endif
switch (get_typeid(node.get_type_info()))
{
case OP_TYPEID::Abs:
......@@ -1654,9 +1651,7 @@ private:
case OP_TYPEID::Unsqueeze:
case OP_TYPEID::UnknownOp:
throw unsupported_op("Unsupported op '" + node.description() + "'");
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
}
};
......@@ -207,12 +207,9 @@ private:
// We want to check that every OP_TYPEID enumeration is included in the list.
// These GCC flags enable compile-time checking so that if an enumeration
// is not in the list an error is generated.
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wcovered-switch-default"
#endif
switch (get_typeid(node.get_type_info()))
{
case OP_TYPEID::Abs:
......@@ -1894,9 +1891,7 @@ private:
case OP_TYPEID::TensorIterator:
case OP_TYPEID::UnknownOp:
throw unsupported_op("Unsupported op '" + node.description() + "'");
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
}
};
......@@ -783,12 +783,9 @@ shared_ptr<Node> JSONDeserializer::deserialize_node(json node_js)
vector<string> node_outputs = get_value<vector<string>>(node_js, "outputs");
OutputVectorHelper args(deserialize_output_vector(node_js["inputs"]));
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wimplicit-fallthrough"
#endif
switch (get_typeid(type_info))
{
......@@ -2962,9 +2959,7 @@ shared_ptr<Node> JSONDeserializer::deserialize_node(json node_js)
throw runtime_error(ss.str());
}
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
for (auto& control_dep : control_deps_inputs)
{
......@@ -3126,12 +3121,9 @@ json JSONSerializer::serialize_node(const Node& n)
node["provenance_tags"] = provenance_tags;
}
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
// #pragma GCC diagnostic error "-Wimplicit-fallthrough"
#endif
switch (get_typeid(type_info))
{
case OP_TYPEID::Abs: { break;
......@@ -4630,8 +4622,6 @@ json JSONSerializer::serialize_node(const Node& n)
case OP_TYPEID::UnknownOp: { break;
}
}
#if !(defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ == 8))
#pragma GCC diagnostic pop
#endif
return node;
}
......@@ -80,11 +80,9 @@ void set_denormals_flush_to_zero()
void random_init(shared_ptr<runtime::Tensor> tensor)
{
element::Type et = tensor->get_element_type();
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (et)
{
case element::Type_t::boolean: init_int_tensor<char>(tensor, 0, 1); break;
......@@ -105,9 +103,7 @@ void random_init(shared_ptr<runtime::Tensor> tensor)
case element::Type_t::f16:
default: throw runtime_error("unsupported type");
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
}
default_random_engine& get_random_engine()
......
......@@ -48,11 +48,9 @@ static void test_allreduce_common(reduction::Type reduce_type)
auto a = backend->create_tensor(element::f32, shape);
auto result = backend->create_tensor(element::f32, shape);
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic push
#pragma GCC diagnostic error "-Wswitch"
#pragma GCC diagnostic error "-Wswitch-enum"
#endif
switch (reduce_type)
{
case reduction::Type::SUM:
......@@ -83,9 +81,7 @@ static void test_allreduce_common(reduction::Type reduce_type)
v[i] = i + 2;
}
}
#if defined(__GNUC__) && !(__GNUC__ == 4 && __GNUC_MINOR__ == 8)
#pragma GCC diagnostic pop
#endif
auto handle = backend->compile(f);
handle->call_with_validate({result}, {a});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment