Unverified Commit 6a560768 authored by Diego Caballero's avatar Diego Caballero Committed by GitHub

Fix some warnings (#4294)

* Fix warnings

Control reaches end of non-void function

* Format

* Revert changes + add throw at EOF

* Alternative fix
Co-authored-by: 's avatarScott Cyphers <diyessi@users.noreply.github.com>
Co-authored-by: 's avatarSang Ik Lee <sang.ik.lee@intel.com>
Co-authored-by: 's avatarRobert Kimball <robert.kimball@intel.com>
parent 925087ba
......@@ -193,75 +193,90 @@ namespace ngraph
std::vector<T> cast_vector() const
{
auto source_type = get_element_type();
std::vector<T> rc;
switch (source_type)
{
case element::Type_t::boolean:
{
auto vector = get_vector<char>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::bf16:
{
auto vector = get_vector<bfloat16>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::f16:
{
auto vector = get_vector<float16>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::f32:
{
auto vector = get_vector<float>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::f64:
{
auto vector = get_vector<double>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::i8:
{
auto vector = get_vector<int8_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::i16:
{
auto vector = get_vector<int16_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::i32:
{
auto vector = get_vector<int32_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::i64:
{
auto vector = get_vector<int64_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::u8:
{
auto vector = get_vector<uint8_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::u16:
{
auto vector = get_vector<uint16_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::u32:
{
auto vector = get_vector<uint32_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
case element::Type_t::u64:
{
auto vector = get_vector<uint64_t>();
return std::vector<T>(vector.begin(), vector.end());
rc = std::vector<T>(vector.begin(), vector.end());
break;
}
default: throw std::runtime_error("unsupported type");
}
return rc;
}
const void* get_data_ptr() const { return (m_data ? m_data->get_ptr() : nullptr); }
......
......@@ -49,6 +49,7 @@ shared_ptr<op::Constant> fold_constant_one_hot(const shared_ptr<op::Constant>& i
const Shape& output_shape,
size_t axis)
{
shared_ptr<op::Constant> rc;
switch (indices->get_element_type())
{
case element::Type_t::undefined:
......@@ -62,31 +63,40 @@ shared_ptr<op::Constant> fold_constant_one_hot(const shared_ptr<op::Constant>& i
NGRAPH_CHECK(false, "Indices input element type must be integer");
break;
case element::Type_t::i8:
return fold_constant_one_hot_ref<int8_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<int8_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
case element::Type_t::i16:
return fold_constant_one_hot_ref<int16_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<int16_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
case element::Type_t::i32:
return fold_constant_one_hot_ref<int32_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<int32_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
case element::Type_t::i64:
return fold_constant_one_hot_ref<int64_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<int64_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
case element::Type_t::u8:
return fold_constant_one_hot_ref<uint8_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<uint8_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
case element::Type_t::u16:
return fold_constant_one_hot_ref<uint16_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<uint16_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
case element::Type_t::u32:
return fold_constant_one_hot_ref<uint32_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<uint32_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
case element::Type_t::u64:
return fold_constant_one_hot_ref<uint64_t, OUTPUT_TYPE>(
rc = fold_constant_one_hot_ref<uint64_t, OUTPUT_TYPE>(
indices, on_value, off_value, output_shape, axis);
break;
default: NGRAPH_CHECK(false, "Indices input element type must be integer");
}
return rc;
}
void pass::ConstantFolding::construct_constant_one_hot()
......
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