Address warning in data_types_internal.h (#6704)

Address "unreachable code" warning in data_types_internal.h.
This commit is contained in:
Edward Chen 2021-02-16 12:41:48 -08:00 committed by GitHub
parent c36ee4bd40
commit b09a370218
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 9 deletions

View file

@ -243,10 +243,11 @@ class CallableDispatchableHelper {
}
};
// Default policy is to throw with no return type.
// Default policy is to throw an exception.
// Other policies may set the second result argument accordingly.
template <class Ret>
struct UnsupportedTypeDefaultPolicy {
Ret operator()(int32_t dt_type) const {
void operator()(int32_t dt_type, Ret& /*result*/) const {
ORT_THROW("Unsupported data type: ", dt_type);
}
};
@ -264,7 +265,7 @@ class CallableDispatchableRetHelper {
Ret Get() {
// No type was invoked
if (called_ == 0) {
result_ = UnsupportedPolicy()(dt_type_);
UnsupportedPolicy()(dt_type_, result_);
}
return result_;
}

View file

@ -909,8 +909,8 @@ static Status CopySparseData(size_t n_sparse_elements,
}
struct UnsupportedSparseDataType {
Status operator()(int32_t dt_type) const {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Unsupported sparse tensor data type of ", dt_type);
void operator()(int32_t dt_type, Status& status) const {
status = ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Unsupported sparse tensor data type of ", dt_type);
}
};
@ -998,7 +998,7 @@ common::Status SparseTensorProtoToDenseTensorProto(const ONNX_NAMESPACE::SparseT
} else {
// No request for std::string
status = UnsupportedSparseDataType()(ONNX_NAMESPACE::TensorProto_DataType_STRING);
UnsupportedSparseDataType()(ONNX_NAMESPACE::TensorProto_DataType_STRING, status);
}
return status;
}
@ -1056,7 +1056,9 @@ common::Status DenseTensorToSparseTensorProto(const ONNX_NAMESPACE::TensorProto&
const bool is_string_data = dense_proto.data_type() == ONNX_NAMESPACE::TensorProto_DataType_STRING;
if (is_string_data) {
return UnsupportedSparseDataType()(ONNX_NAMESPACE::TensorProto_DataType_STRING);
Status status{};
UnsupportedSparseDataType()(ONNX_NAMESPACE::TensorProto_DataType_STRING, status);
return status;
}
const auto data_type = dense_proto.data_type();

View file

@ -1267,10 +1267,10 @@ struct CallGetValueImpl {
// Return status instead of throwing if unsupported type specified
struct UnsupportedReturnFailStatus {
ORT_STATUS_PTR operator()(int32_t dt_type) const {
void operator()(int32_t dt_type, OrtStatusPtr& status) const {
std::string msg("Unsupported tensor element type in the input: ");
msg.append(std::to_string(dt_type));
return OrtApis::CreateStatus(ORT_FAIL, msg.c_str());
status = OrtApis::CreateStatus(ORT_FAIL, msg.c_str());
}
};
} // namespace c_api_internal