Skip to content

Commit 3d75215

Browse files
committed
Added utilization of OpenMP
1 parent b48e87b commit 3d75215

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/diwa.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ double* Diwa::inference(double *inputNeurons) {
145145
memcpy(this->outputs, inputNeurons, sizeof(double) * this->inputNeurons);
146146
if(!this->hiddenLayers) {
147147
double *returnValues = outputs;
148+
149+
#pragma omp parallel for
148150
for(int j = 0; j < this->outputNeurons; ++j) {
149151
double sum = *weights++ * -1.0;
150152

@@ -166,6 +168,7 @@ double* Diwa::inference(double *inputNeurons) {
166168

167169
inputs += this->inputNeurons;
168170
for(int h = 1; h < this->hiddenLayers; ++h) {
171+
#pragma omp parallel for
169172
for(int j = 0; j < this->hiddenNeurons; ++j) {
170173
double sum = *weights++ * -1.0;
171174

@@ -178,6 +181,8 @@ double* Diwa::inference(double *inputNeurons) {
178181
}
179182

180183
double* returnValue = outputs;
184+
185+
#pragma omp parallel for
181186
for(int j = 0; j < this->outputNeurons; ++j) {
182187
double sum = *weights++ * -1.0;
183188

@@ -270,6 +275,7 @@ void Diwa::train(double learningRate, double *inputNeurons, double *outputNeuron
270275
(this->inputNeurons + this->hiddenNeurons *
271276
(this->hiddenLayers - 1)) : 0);
272277

278+
#pragma omp parallel for
273279
for(int j = 0; j < this->outputNeurons; ++j) {
274280
*weights++ += *deltas * learningRate * -1.0;
275281

@@ -297,6 +303,7 @@ void Diwa::train(double learningRate, double *inputNeurons, double *outputNeuron
297303
(this->hiddenNeurons + 1) * this->hiddenNeurons *
298304
(h - 1) : 0);
299305

306+
#pragma omp parallel for
300307
for(int j = 0; j < this->hiddenNeurons; ++j) {
301308
*weights += *deltas * learningRate * -1.0;
302309

0 commit comments

Comments
 (0)