Skip to content

Commit

Permalink
Merge pull request #294 from clEsperanto/master
Browse files Browse the repository at this point in the history
fix multiply image and positions
  • Loading branch information
StRigaud committed May 3, 2024
2 parents 442a19f + 384f6c0 commit cb6e1af
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion clic/src/tier1/multiply_image_and_position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ multiply_image_and_position_func(const Device::Pointer & device,
Array::Pointer dst,
int dimension) -> Array::Pointer
{
tier0::create_like(src, dst);
tier0::create_like(src, dst, dType::FLOAT);
const KernelInfo kernel = { "multiply_image_and_position", kernel::multiply_image_and_position };
const ParameterList params = { { "src", src }, { "dst", dst }, { "index", dimension } };
const RangeArray range = { dst->width(), dst->height(), dst->depth() };
Expand Down
4 changes: 1 addition & 3 deletions clic/src/tier3/bounding_box.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ auto
bounding_box_func(const Device::Pointer & device, const Array::Pointer & src) -> std::array<float, 6>
{
float min_x = 0, min_y = 0, min_z = 0, max_x = 0, max_y = 0, max_z = 0;
auto temp = Array::create(
src->width(), src->height(), src->depth(), src->dimension(), dType::INDEX, mType::BUFFER, src->device());
tier1::multiply_image_and_position_func(device, src, temp, 0);
auto temp = tier1::multiply_image_and_position_func(device, src, nullptr, 0);
max_x = tier2::maximum_of_all_pixels_func(device, temp);
min_x = tier2::minimum_of_masked_pixels_func(device, temp, src);
temp = tier1::multiply_image_and_position_func(device, src, nullptr, 1);
Expand Down
21 changes: 21 additions & 0 deletions tests/tier1/test_multiply_image_and_position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,27 @@ TEST_P(TestMultiplyPixelAndCoord, execute)
}
}

TEST_P(TestMultiplyPixelAndCoord, returnType)
{
std::string param = GetParam();
cle::BackendManager::getInstance().setBackend(param);
auto device = cle::BackendManager::getInstance().getBackend().getDevice("", "all");
device->setWaitToFinish(true);

for (cle::dType type : { cle::dType::UINT8,
cle::dType::INT8,
cle::dType::UINT16,
cle::dType::INT16,
cle::dType::FLOAT,
cle::dType::UINT32,
cle::dType::INT32 })
{
auto gpu_input = cle::Array::create(5, 3, 1, 3, type, cle::mType::BUFFER, device);
auto gpu_output = cle::tier1::multiply_image_and_position_func(device, gpu_input, nullptr, 0);
EXPECT_EQ(gpu_output->dtype(), cle::dType::FLOAT);
}
}

std::vector<std::string>
getParameters()
{
Expand Down

0 comments on commit cb6e1af

Please sign in to comment.