From 66bd42adfa57b5f3148e87525da721fbf47da910 Mon Sep 17 00:00:00 2001 From: John Richardson Date: Thu, 12 Oct 2017 12:15:23 +0100 Subject: COMPMID-620: Throw a FileNotFound error when FixedPoint npy files are missing Change-Id: I511c303c9412619b5b43931b2571805854bffee3 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/91528 Tested-by: Kaizen Reviewed-by: Anthony Barbier --- tests/validation/UNIT/FixedPoint.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/validation/UNIT/FixedPoint.cpp b/tests/validation/UNIT/FixedPoint.cpp index 627a779f5f..66a4b25fc9 100644 --- a/tests/validation/UNIT/FixedPoint.cpp +++ b/tests/validation/UNIT/FixedPoint.cpp @@ -44,6 +44,19 @@ const auto FuncNamesDataset = framework::dataset::make("FunctionNames", { FixedP FixedPointOp::LOG, FixedPointOp::INV_SQRT }); + +template +void load_array_from_numpy(const std::string &file, std::vector &shape, std::vector &data) // NOLINT +{ + try + { + npy::LoadArrayFromNumpy(file, shape, data); + } + catch(const std::runtime_error &e) + { + throw framework::FileNotFound("Could not load npy file: " + file + " (" + e.what() + ")"); + } +} } // namespace TEST_SUITE(UNIT) @@ -71,8 +84,7 @@ DATA_TEST_CASE(FixedPointQS8Inputs, framework::DatasetMode::ALL, combine( + support::cpp11::to_string(frac_bits) + ".in.npy"; - ARM_COMPUTE_TEST_INFO(inputs_file); - npy::LoadArrayFromNumpy(inputs_file, shape, data); + load_array_from_numpy(inputs_file, shape, data); // Values stored as doubles so reinterpret as floats const auto *float_val = reinterpret_cast(&data[0]); @@ -126,11 +138,8 @@ DATA_TEST_CASE(FixedPointQS8Outputs, framework::DatasetMode::ALL, zip(combine( const std::string inputs_file = base_file_name + ".in.npy"; const std::string reference_file = base_file_name + ".out.npy"; - ARM_COMPUTE_TEST_INFO(base_file_name + ".in"); - npy::LoadArrayFromNumpy(inputs_file, in_shape, in_data); - - ARM_COMPUTE_TEST_INFO(base_file_name + ".out"); - npy::LoadArrayFromNumpy(reference_file, out_shape, out_data); + load_array_from_numpy(inputs_file, in_shape, in_data); + load_array_from_numpy(reference_file, out_shape, out_data); ARM_COMPUTE_EXPECT(in_shape.front() == out_shape.front(), framework::LogLevel::ERRORS); -- cgit v1.2.1