mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-02 03:55:34 +00:00
Upgrade gtest to the latest version (#2827)
WinML would like to update the googletest submodule. They want some newer features (namely GTEST_SKIP to skip tests programmatically and be able to skip entire fixtures easily) and would need to update the submodule version. However, because the new version of code hit a bug in gcc, even though the bug is already fixed in the latest gcc but we're using gcc 4.8.x and it won't get patched for the bug, so we have to do a compromise, change our code a little bit to make it work. The gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
This commit is contained in:
parent
120433c29d
commit
5c391854f4
9 changed files with 28 additions and 15 deletions
|
|
@ -22,7 +22,7 @@
|
|||
"component": {
|
||||
"type": "git",
|
||||
"git": {
|
||||
"commitHash": "9bda90b7e5e08c4c37a832d0cea218aed6af6470",
|
||||
"commitHash": "703bd9caab50b139428cea1aaff9974ebee5742e",
|
||||
"repositoryUrl": "https://github.com/google/googletest.git"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
cmake/external/googletest
vendored
2
cmake/external/googletest
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit 9bda90b7e5e08c4c37a832d0cea218aed6af6470
|
||||
Subproject commit 703bd9caab50b139428cea1aaff9974ebee5742e
|
||||
|
|
@ -90,7 +90,8 @@ TEST_F(ExecutionFrameTest, TensorAllocationTest) {
|
|||
OrtValue* p_ml_value = frame.GetMutableNodeInputOrOutputMLValue(0);
|
||||
Tensor* p_tensor = p_ml_value ? p_ml_value->GetMutable<Tensor>() : nullptr;
|
||||
EXPECT_TRUE(p_tensor);
|
||||
EXPECT_EQ(p_tensor->Shape(), shape);
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&p_tensor->Shape()), *reinterpret_cast<const std::vector<int64_t>*>(&shape));
|
||||
EXPECT_EQ(p_tensor->DataType(), DataTypeImpl::GetType<float>());
|
||||
|
||||
//test share memory from tensor
|
||||
|
|
@ -106,7 +107,8 @@ TEST_F(ExecutionFrameTest, TensorAllocationTest) {
|
|||
const OrtValue* p_ml_value_const = frame.GetNodeInputOrOutputMLValue(1);
|
||||
auto tensor2 = p_ml_value_const ? &(p_ml_value_const->Get<Tensor>()) : nullptr;
|
||||
EXPECT_TRUE(tensor2);
|
||||
EXPECT_EQ(tensor2->Shape(), shape2);
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&tensor2->Shape()), *reinterpret_cast<const std::vector<int64_t>*>(&shape2));
|
||||
EXPECT_EQ(tensor2->template Data<float>(), p_tensor->template Data<float>());
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +157,8 @@ TEST_F(ExecutionFrameTest, FeedInDataTest) {
|
|||
OrtValue* p_ml_value = frame.GetMutableNodeInputOrOutputMLValue(0);
|
||||
Tensor* p_tensor_arg_0 = p_ml_value ? p_ml_value->GetMutable<Tensor>() : nullptr;
|
||||
EXPECT_TRUE(p_tensor_arg_0);
|
||||
EXPECT_EQ(p_tensor_arg_0->Shape(), shape);
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&p_tensor_arg_0->Shape()), *reinterpret_cast<const std::vector<int64_t>*>(&shape));
|
||||
EXPECT_EQ(p_tensor_arg_0->DataType(), DataTypeImpl::GetType<float>());
|
||||
EXPECT_EQ(p_tensor_arg_0->MutableData<float>(), value.GetMutable<Tensor>()->MutableData<float>());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,8 @@ void RunSession(InferenceSession& session_object,
|
|||
ASSERT_EQ(1, fetches.size());
|
||||
auto& rtensor = fetches.front().Get<Tensor>();
|
||||
TensorShape expected_shape(dims_y);
|
||||
EXPECT_EQ(expected_shape, rtensor.Shape());
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&expected_shape), *reinterpret_cast<const std::vector<int64_t>*>(&rtensor.Shape()));
|
||||
const std::vector<MLFloat16> found(rtensor.template Data<MLFloat16>(), rtensor.template Data<MLFloat16>() + expected_shape.Size());
|
||||
ASSERT_EQ(found.size(), values_y.size());
|
||||
for (size_t i = 0; i < found.size(); i++)
|
||||
|
|
|
|||
|
|
@ -176,7 +176,8 @@ template <typename T = float>
|
|||
void VerifyOutputs(const Tensor& tensor, const std::vector<int64_t>& expected_dims,
|
||||
const std::vector<T>& expected_values) {
|
||||
TensorShape expected_shape(expected_dims);
|
||||
ASSERT_EQ(expected_shape, tensor.Shape());
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
ASSERT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&expected_shape), *reinterpret_cast<const std::vector<int64_t>*>(&tensor.Shape()));
|
||||
const std::vector<T> found(tensor.template Data<T>(),
|
||||
tensor.template Data<T>() + expected_values.size());
|
||||
ASSERT_EQ(expected_values, found);
|
||||
|
|
@ -1312,7 +1313,8 @@ TEST(InferenceSessionTests, TestTruncatedSequence) {
|
|||
ASSERT_EQ(1, fetches.size());
|
||||
auto& rtensor = fetches.front().Get<Tensor>();
|
||||
TensorShape expected_shape(Y_dims);
|
||||
ASSERT_EQ(expected_shape, rtensor.Shape());
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
ASSERT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&expected_shape), *reinterpret_cast<const std::vector<int64_t>*>(&rtensor.Shape()));
|
||||
for (size_t i = 0; i < Y_data.size(); ++i)
|
||||
EXPECT_NEAR(Y_data[i], rtensor.template Data<float>()[i], FLT_EPSILON);
|
||||
|
||||
|
|
@ -1354,7 +1356,8 @@ TEST(InferenceSessionTests, TestTruncatedSequence) {
|
|||
std::vector<int64_t> truncated_output_dims = Y_dims;
|
||||
truncated_output_dims[0] = truncated_len;
|
||||
TensorShape truncated_shape(truncated_output_dims);
|
||||
ASSERT_EQ(truncated_shape, truncated_rtensor.Shape());
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
ASSERT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&truncated_shape), *reinterpret_cast<const std::vector<int64_t>*>(&truncated_rtensor.Shape()));
|
||||
auto seq_output_stride = truncated_shape.SizeFromDimension(1);
|
||||
for (int i = 0; i < truncated_shape.Size(); ++i)
|
||||
EXPECT_NEAR(Y_data[i + seq_start * seq_output_stride], truncated_rtensor.template Data<float>()[i], FLT_EPSILON);
|
||||
|
|
|
|||
|
|
@ -214,7 +214,8 @@ void RunSession(InferenceSession& session_object,
|
|||
ASSERT_EQ(1, fetches.size());
|
||||
auto& rtensor = fetches.front().Get<Tensor>();
|
||||
TensorShape expected_shape(dims_y);
|
||||
EXPECT_EQ(expected_shape, rtensor.Shape());
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&expected_shape), *reinterpret_cast<const std::vector<int64_t>*>(&rtensor.Shape()));
|
||||
const std::vector<float> found(rtensor.template Data<float>(), rtensor.template Data<float>() + expected_shape.Size());
|
||||
ASSERT_EQ(values_y, found);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,8 @@ void CPUTensorTest(std::vector<int64_t> dims, const int offset = 0) {
|
|||
EXPECT_TRUE(data);
|
||||
Tensor t(DataTypeImpl::GetType<T>(), shape, data, alloc->Info(), offset);
|
||||
auto tensor_shape = t.Shape();
|
||||
EXPECT_EQ(shape, tensor_shape);
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&shape), *reinterpret_cast<const std::vector<int64_t>*>(&tensor_shape));
|
||||
EXPECT_EQ(t.DataType(), DataTypeImpl::GetType<T>());
|
||||
auto& location = t.Location();
|
||||
EXPECT_STREQ(location.name, CPU);
|
||||
|
|
@ -36,7 +37,8 @@ void CPUTensorTest(std::vector<int64_t> dims, const int offset = 0) {
|
|||
Tensor new_t(DataTypeImpl::GetType<T>(), shape, alloc, offset);
|
||||
|
||||
tensor_shape = new_t.Shape();
|
||||
EXPECT_EQ(shape, tensor_shape);
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&shape), *reinterpret_cast<const std::vector<int64_t>*>(&tensor_shape));
|
||||
EXPECT_EQ(new_t.DataType(), DataTypeImpl::GetType<T>());
|
||||
auto& new_location = new_t.Location();
|
||||
ASSERT_STREQ(new_location.name, CPU);
|
||||
|
|
@ -150,7 +152,8 @@ TEST(TensorTest, StringTensorTest) {
|
|||
Tensor t(DataTypeImpl::GetType<std::string>(), shape, alloc);
|
||||
|
||||
auto& tensor_shape = t.Shape();
|
||||
EXPECT_EQ(shape, tensor_shape);
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
EXPECT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&shape), *reinterpret_cast<const std::vector<int64_t>*>(&tensor_shape));
|
||||
EXPECT_EQ(t.DataType(), DataTypeImpl::GetType<std::string>());
|
||||
auto& location = t.Location();
|
||||
ASSERT_STREQ(location.name, CPU);
|
||||
|
|
|
|||
|
|
@ -678,7 +678,8 @@ TEST(GraphTransformationTests, FuseConvBnAddMulFloat16) {
|
|||
ASSERT_EQ(1, fetches.size());
|
||||
auto& rtensor = fetches.front().Get<Tensor>();
|
||||
TensorShape expected_shape(expected_dims_prod);
|
||||
ASSERT_EQ(expected_shape, rtensor.Shape());
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
ASSERT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&expected_shape), *reinterpret_cast<const std::vector<int64_t>*>(&rtensor.Shape()));
|
||||
const std::vector<MLFloat16> found(rtensor.template Data<MLFloat16>(),
|
||||
rtensor.template Data<MLFloat16>() + expected_dims_prod.size());
|
||||
ASSERT_EQ(expected_values_prod, found);
|
||||
|
|
|
|||
|
|
@ -620,7 +620,8 @@ TEST(Loop, SubgraphInputShadowsOuterScopeValue) {
|
|||
|
||||
auto& b_out = fetches[0].Get<Tensor>();
|
||||
TensorShape expected_shape(scalar);
|
||||
ASSERT_EQ(expected_shape, b_out.Shape());
|
||||
//Use reinterpret_cast to bypass a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51213
|
||||
ASSERT_EQ(*reinterpret_cast<const std::vector<int64_t>*>(&expected_shape), *reinterpret_cast<const std::vector<int64_t>*>(&b_out.Shape()));
|
||||
ASSERT_EQ(b_out.DataAsSpan<float>()[0], expected_value_b);
|
||||
|
||||
auto user_defined_vals_out = fetches[1].Get<Tensor>().DataAsSpan<float>();
|
||||
|
|
|
|||
Loading…
Reference in a new issue