@@ -21,38 +21,41 @@ using TestType = int;
2121
2222class NesterovARunFuncTests : public ppc ::util::BaseRunFuncTests<InType, OutType, TestType> {
2323 public:
24- static std::string CustomFuncTestName (
25- const ::testing::TestParamInfo<ppc::util::FuncTestParam<InType, OutType, TestType>>& info) {
26- std::string test_name = std::get<ppc::util::FuncTestParamIndex::kNameTest >(info.param );
27- std::string test_param = std::to_string (std::get<ppc::util::FuncTestParamIndex::kTestParams >(info.param ));
28- return test_name + " _" + test_param;
29- }
24+ static std::string CustomFuncTestName (
25+ const ::testing::TestParamInfo<ppc::util::FuncTestParam<InType, OutType, TestType>> & info) {
26+ std::string test_name = std::get<ppc::util::FuncTestParamIndex::kNameTest >(info.param );
27+ std::string test_param = std::to_string (std::get<ppc::util::FuncTestParamIndex::kTestParams >(info.param ));
28+ return test_name + " _" + test_param;
29+ }
3030
3131 protected:
3232 void SetUp () override {
33+ PrepareData ();
34+ GetTaskPtr () = std::get<ppc::util::FuncTestParamIndex::kTaskGetter >(GetParam ())(GetTestInput ());
35+ }
36+
37+ void PrepareData () {
38+ int width = -1 ;
39+ int height = -1 ;
40+ int channels = -1 ;
3341 // Read image
34- std::string abs_path = ppc::util::GetAbsolutePath (" example/tests/data/pic_all.jpg" );
35- data = stbi_load (abs_path.c_str (), &width, &height, &channels, 0 );
36- ASSERT_TRUE (data != nullptr ) << " Failed to load image: " << stbi_failure_reason ();
37- img = std::vector<uint8_t >(data, data + (static_cast <ptrdiff_t >(width * height * channels)));
38- stbi_image_free (data);
39- ASSERT_EQ (width, height);
42+ {
43+ std::string abs_path = ppc::util::GetAbsolutePath (" example/tests/data/pic_all.jpg" );
44+ auto *data = stbi_load (abs_path.c_str (), &width, &height, &channels, 0 );
45+ ASSERT_TRUE (data != nullptr ) << " Failed to load image: " << stbi_failure_reason ();
46+ auto img = std::vector<uint8_t >(data, data + (static_cast <ptrdiff_t >(width * height * channels)));
47+ stbi_image_free (data);
48+ ASSERT_EQ (width, height);
49+ }
4050
4151 const int k_count = (width + height) / std::get<ppc::util::FuncTestParamIndex::kTestParams >(GetParam ());
42- std::vector< int > in (static_cast <std::vector<int >::size_type>(k_count * k_count), 0 );
52+ GetTestInput () = InType (static_cast <std::vector<int >::size_type>(k_count * k_count), 0 );
4353 for (int i = 0 ; i < k_count; i++) {
44- in [(i * k_count) + i] = 1 ;
54+ GetTestInput () [(i * k_count) + i] = 1 ;
4555 }
46- GetTaskPtr () = std::get<ppc::util::FuncTestParamIndex::kTaskGetter >(GetParam ())(in);
47- }
48-
49- void CheckTestOutputData () final {
50- EXPECT_EQ (GetTaskPtr ()->GetInput (), GetTaskPtr ()->GetOutput ());
5156 }
5257
53- int width = -1 , height = -1 , channels = -1 ;
54- unsigned char * data = nullptr ;
55- std::vector<uint8_t > img;
58+ void CheckTestOutputData () final { EXPECT_EQ (GetTestInput (), GetTaskPtr ()->GetOutput ()); }
5659};
5760
5861TEST_P (NesterovARunFuncTests, MatmulFromPic) { ExecuteTest (); }
0 commit comments