-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel of Laplace Box #157
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7953558
Creating files & implementing funtions
e6055a6
Creating cpp file & implementing functions
76ba4a8
Adding tests
93ebf2c
test modification
5302d42
formatting the code
bf30160
Merge branch 'clEsperanto:master' into kernel_laplace_box
CherifMZ 4a4a517
Updating LaplaceBoxKernel.cpp and test files
09b471a
testing with local branch
f60769c
Updating the repository link and the tag
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
|
||
#ifndef __TIER1_CLELAPLACEBOXKERNEL_HPP | ||
#define __TIER1_CLELAPLACEBOXKERNEL_HPP | ||
|
||
#include "cleOperation.hpp" | ||
|
||
namespace cle | ||
{ | ||
|
||
class LaplaceBoxKernel : public Operation | ||
{ | ||
public: | ||
explicit LaplaceBoxKernel(const ProcessorPointer & device); | ||
auto | ||
SetInput(const Image & object) -> void; | ||
auto | ||
SetOutput(const Image & object) -> void; | ||
}; | ||
|
||
inline auto | ||
LaplaceBoxKernel_Call(const std::shared_ptr<cle::Processor> & device, const Image & src, const Image & dst) -> void | ||
{ | ||
LaplaceBoxKernel kernel(device); | ||
kernel.SetInput(src); | ||
kernel.SetOutput(dst); | ||
kernel.Execute(); | ||
} | ||
|
||
} // namespace cle | ||
|
||
#endif // __TIER1_CLELAPLACEBOXKERNEL_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
|
||
#include "cleLaplaceBoxKernel.hpp" | ||
#include "cle_laplace_box.h" | ||
|
||
namespace cle | ||
{ | ||
|
||
LaplaceBoxKernel::LaplaceBoxKernel(const ProcessorPointer & device) | ||
: Operation(device, 2) | ||
{ | ||
this->SetSource("laplace_box", oclKernel::laplace_box); | ||
} | ||
|
||
auto | ||
LaplaceBoxKernel::SetInput(const Image & object) -> void | ||
{ | ||
this->AddParameter("src", object); | ||
} | ||
|
||
auto | ||
LaplaceBoxKernel::SetOutput(const Image & object) -> void | ||
{ | ||
this->AddParameter("dst", object); | ||
} | ||
|
||
} // namespace cle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
|
||
|
||
#include "clesperanto.hpp" | ||
|
||
template <class type> | ||
auto | ||
run_test(const std::array<size_t, 3> & shape, const cle::MemoryType & mem_type) -> bool | ||
{ | ||
std::vector<type> input(shape[0] * shape[1] * shape[2]); | ||
std::vector<type> valid(shape[0] * shape[1] * shape[2]); | ||
|
||
if (shape[2] > 1) | ||
{ | ||
input = { 1, 0, 2, 1, 0, 1, 0, 3, 0, 2, 0, 1, 3, 0, 0, 1, 0, 1, 1, 0, 2, 0, 2, 1 }; | ||
valid = { 4, -22, 30, -6, -21, 6, -26, 50, -19, 34, -28, -2, 50, -23, -18, 3, -27, 3, 5, -26, 31, -25, 28, -1 }; | ||
} | ||
else if (shape[1] > 1) | ||
{ | ||
input = { 1, 0, 2, 1, 0, 1, 3, 1, 0, 2, 1, 1 }; | ||
valid = { 3, -8, 8, -2, -9, 2, 13, -1, -6, 1, -3, 2 }; | ||
} | ||
else | ||
{ | ||
input = { 1, 0, 0, 1, 1 }; | ||
valid = { 1, -1, -1, 1, 0 }; | ||
} | ||
|
||
cle::Clesperanto cle; | ||
cle.GetDevice()->WaitForKernelToFinish(); | ||
auto gpu_input = cle.Push<type>(input, shape, mem_type); | ||
auto gpu_output = cle.Create<type>(shape, mem_type); | ||
cle.LaplaceBox(gpu_input, gpu_output); | ||
auto output = cle.Pull<type>(gpu_output); | ||
|
||
return std::equal(output.begin(), output.end(), valid.begin()); | ||
} | ||
|
||
auto | ||
main(int argc, char ** argv) -> int | ||
{ | ||
if (!run_test<float>({ 5, 1, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int32_t>({ 5, 1, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int16_t>({ 5, 1, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int8_t>({ 5, 1, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<float>({ 3, 4, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int32_t>({ 3, 4, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int16_t>({ 3, 4, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int8_t>({ 3, 4, 1 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<float>({ 4, 3, 2 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int32_t>({ 4, 3, 2 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int16_t>({ 4, 3, 2 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
if (!run_test<int8_t>({ 4, 3, 2 }, cle::BUFFER)) | ||
{ | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kernel is pushed to the clesperanto_kernel branch, you can update back the repository link and tag before final merge