[Add] Dropout Operator
Context
Update the cpu.hpp file and add the following new files for the dropout implementation based on the Bernoulli distribution:
- DropoutImp_forward_kernels.hpp
- DropoutImp.hpp
- DropoutImpl.cpp
Part of: aidge_core#183
Modified files
- aidge/aidge_backend_cpu/include/aidge/backend/cpu.hpp
Added files
- aidge_backend_cpu/include/aidge/backend/cpu/operator/DropoutImpl_forward_kernels.hpp
- aidge_backend_cpu/include/aidge/backend/cpu/operator/DropoutImpl.hpp
- aidge_backend_cpu/src/operator/DropoutImpl.cpp
- add: unit-test
Test_DropoutImpl.cpp
Merge request reports
Activity
added Feature 🚀 label
assigned to @maab05
added StatusReview Ready label
added TopicOperator label
requested review from @pineapple
requested review from @noamzerah
Since the last update, the way implementations are handled has been revisited. It is shorter, and you can easily adapt your code. Here is an example with FC operator: https://gitlab.eclipse.org/eclipse/aidge/aidge_backend_cpu/-/blob/main/include/aidge/backend/cpu/operator/FCImpl.hpp?ref_type=heads It implements both forward and backward kernels
You should also take a look at SliceImpl. It only implements a forward kernel.
- Resolved by Marwa ABDELOUINISSE
- Resolved by Marwa ABDELOUINISSE
- src/operator/DropoutImpl.cpp 0 → 100644
14 #include <numeric> 15 #include <thread> 16 #include <vector> 17 18 #include "aidge/operator/Dropout.hpp" 19 #include "aidge/utils/Types.h" 20 #include "aidge/data/Tensor.hpp" 21 22 #include "aidge/backend/cpu/operator/DropoutImpl.hpp" 23 #include "aidge/backend/cpu/operator/DropoutImpl_forward_kernels.hpp" 24 25 void Aidge::DropoutImpl_cpu::forward() { 26 // Safely cast mOp to Dropout_Op and handle any error if the cast fails 27 const Dropout_Op* op_ = dynamic_cast<const Dropout_Op*>(&mOp); 28 if (!op_) { 29 throw std::runtime_error("DropoutImpl_cpu::forward: mOp is not of type Dropout_Op"); changed this line in version 4 of the diff
- src/operator/DropoutImpl.cpp 0 → 100644
44 op_->getInput(0)->dataType(), 45 op_->getOutput(0)->dataType()}); 46 47 // Check if kernel function was successfully created 48 if (!kernelFunc) { 49 throw std::runtime_error("DropoutImpl_cpu::forward: Failed to create kernel function"); 50 } 51 52 // // Call Kernel 53 // kernelFunc(dynamic_cast<const Dropout_Op&>(mOp).getStaticAttributes(), 54 // op_->getInput(0)->dims(), // Input tensor dimensions 55 // op_->getInput(0)->getImpl()->rawPtr(), // Raw pointer to input data 56 // op_->getOutput(0)->getImpl()->rawPtr()); // Raw pointer to output data 57 58 // Call the forward kernel function 59 kernelFunc( changed this line in version 4 of the diff
mentioned in merge request aidge!73
added StatusWork in Progress label and removed StatusReview Ready label
added 83 commits
-
cfd6fba9...ed718fc0 - 81 commits from branch
eclipse/aidge:dev
- 740a27ba - Merge branch 'dev' into 'main'
- 788a5e7b - Merge branch aidge_backend_cpu:main into feat_183_add_dropout
-
cfd6fba9...ed718fc0 - 81 commits from branch