Skip to content

Commit c4cb109

Browse files
committed
Ensure consistent RGB image loading across tasks and re-enable previously disabled test.
1 parent 00a840d commit c4cb109

File tree

8 files changed

+13
-10
lines changed

8 files changed

+13
-10
lines changed
-15 KB
Loading

tasks/example_processes/tests/functional/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ class NesterovARunFuncTestsProcesses : public ppc::util::BaseRunFuncTests<InType
3232
int height = -1;
3333
int channels = -1;
3434
std::vector<uint8_t> img;
35-
// Read image
35+
// Read image in RGB to ensure consistent channel count
3636
{
3737
std::string abs_path = ppc::util::GetAbsoluteTaskPath(PPC_ID_example_processes, "pic.jpg");
38-
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
38+
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, STBI_rgb);
3939
if (data == nullptr) {
4040
throw std::runtime_error("Failed to load image: " + std::string(stbi_failure_reason()));
4141
}
42+
channels = STBI_rgb;
4243
img = std::vector<uint8_t>(data, data + (static_cast<ptrdiff_t>(width * height * channels)));
4344
stbi_image_free(data);
4445
if (std::cmp_not_equal(width, height)) {
-15 KB
Loading

tasks/example_processes_2/tests/functional/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ class NesterovARunFuncTestsProcesses2 : public ppc::util::BaseRunFuncTests<InTyp
3232
int height = -1;
3333
int channels = -1;
3434
std::vector<uint8_t> img;
35-
// Read image
35+
// Read image in RGB to ensure consistent channel count
3636
{
3737
std::string abs_path = ppc::util::GetAbsoluteTaskPath(PPC_ID_example_processes_2, "pic.jpg");
38-
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
38+
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, STBI_rgb);
3939
if (data == nullptr) {
4040
throw std::runtime_error("Failed to load image: " + std::string(stbi_failure_reason()));
4141
}
42+
channels = STBI_rgb;
4243
img = std::vector<uint8_t>(data, data + (static_cast<ptrdiff_t>(width * height * channels)));
4344
stbi_image_free(data);
4445
if (std::cmp_not_equal(width, height)) {
-15 KB
Loading

tasks/example_processes_3/tests/functional/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ class NesterovARunFuncTestsProcesses3 : public ppc::util::BaseRunFuncTests<InTyp
3232
int height = -1;
3333
int channels = -1;
3434
std::vector<uint8_t> img;
35-
// Read image
35+
// Read image in RGB to ensure consistent channel count
3636
{
3737
std::string abs_path = ppc::util::GetAbsoluteTaskPath(PPC_ID_example_processes_3, "pic.jpg");
38-
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
38+
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, STBI_rgb);
3939
if (data == nullptr) {
4040
throw std::runtime_error("Failed to load image: " + std::string(stbi_failure_reason()));
4141
}
42+
channels = STBI_rgb;
4243
img = std::vector<uint8_t>(data, data + (static_cast<ptrdiff_t>(width * height * channels)));
4344
stbi_image_free(data);
4445
if (std::cmp_not_equal(width, height)) {

tasks/example_threads/data/pic.jpg

-15 KB
Loading

tasks/example_threads/tests/functional/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ class NesterovARunFuncTestsThreads : public ppc::util::BaseRunFuncTests<InType,
3535
int height = -1;
3636
int channels = -1;
3737
std::vector<uint8_t> img;
38-
// Read image
38+
// Read image in RGB to ensure consistent channel count
3939
{
4040
std::string abs_path = ppc::util::GetAbsoluteTaskPath(std::string(PPC_ID_example_threads), "pic.jpg");
41-
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, 0);
41+
auto *data = stbi_load(abs_path.c_str(), &width, &height, &channels, STBI_rgb);
4242
if (data == nullptr) {
4343
throw std::runtime_error("Failed to load image: " + std::string(stbi_failure_reason()));
4444
}
45+
channels = STBI_rgb;
4546
img = std::vector<uint8_t>(data, data + (static_cast<ptrdiff_t>(width * height * channels)));
4647
stbi_image_free(data);
4748
if (std::cmp_not_equal(width, height)) {
@@ -67,8 +68,7 @@ class NesterovARunFuncTestsThreads : public ppc::util::BaseRunFuncTests<InType,
6768

6869
namespace {
6970

70-
// TODO(allnes): Fix & enable back this test
71-
TEST_P(NesterovARunFuncTestsThreads, DISABLED_MatmulFromPic) {
71+
TEST_P(NesterovARunFuncTestsThreads, MatmulFromPic) {
7272
ExecuteTest(GetParam());
7373
}
7474

0 commit comments

Comments
 (0)