Skip to content

Commit

Permalink
fix bug of grad_v_init
Browse files Browse the repository at this point in the history
  • Loading branch information
fangwei123456 committed Mar 19, 2023
1 parent 74fa120 commit 2941330
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
15 changes: 8 additions & 7 deletions docs/source/activation_based/cupy_neuron.rst
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ BPTT函数的输出为:
#include <cuda_fp16.h>
extern "C" __global__
void NeuronBPTTKernel_float_hard_reset_nodetach_reset(
const int & numel, const int & N, const float * grad_spike_seq, const float * grad_v_seq, const float * h_seq, float * grad_x_seq, float * grad_v_init, float & v_th, float & v_reset
const int & N, const float * grad_spike_seq, float * grad_v_init, const float * grad_v_seq, float * grad_x_seq, const float * h_seq, const int & numel, float & v_reset, float & v_th
)

{
Expand Down Expand Up @@ -462,12 +462,13 @@ BPTT函数的输出为:

}

// grad_h_to_x should be defined here!;
grad_v_init[index] = grad_h * grad_h_to_x;
// grad_h_next_to_v should be defined here!;
grad_v_init[index] = grad_h * grad_h_next_to_v;

}
}



上述代码中注释的位置,即提示我们需要补充的位置。它们在 ``NeuronBPTTKernel`` 中有对应的函数:

Expand Down Expand Up @@ -550,8 +551,8 @@ BPTT函数的输出为:

#include <cuda_fp16.h>
extern "C" __global__
void NeuronBPTTKernel_float_hard_reset_nodetach_reset(
const int & numel, const int & N, const float * grad_spike_seq, const float * grad_v_seq, const float * h_seq, float * grad_x_seq, float * grad_v_init, float & v_th, float & v_reset
void IFNodeBPTTKernel_float_hard_reset_nodetach_reset(
const int & N, const float * grad_spike_seq, float * grad_v_init, const float * grad_v_seq, float * grad_x_seq, const float * h_seq, const int & numel, float & v_reset, float & v_th
)

{
Expand Down Expand Up @@ -588,8 +589,8 @@ BPTT函数的输出为:

}

const float grad_h_to_x = 1.0f;
grad_v_init[index] = grad_h * grad_h_to_x;
const float grad_h_next_to_v = 1.0f;
grad_v_init[index] = grad_h * grad_h_next_to_v;

}
}
Expand Down
14 changes: 7 additions & 7 deletions docs/source/activation_based_en/cupy_neuron.rst
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ The outputs are:
#include <cuda_fp16.h>
extern "C" __global__
void NeuronBPTTKernel_float_hard_reset_nodetach_reset(
const int & numel, const int & N, const float * grad_spike_seq, const float * grad_v_seq, const float * h_seq, float * grad_x_seq, float * grad_v_init, float & v_th, float & v_reset
const int & N, const float * grad_spike_seq, float * grad_v_init, const float * grad_v_seq, float * grad_x_seq, const float * h_seq, const int & numel, float & v_reset, float & v_th
)

{
Expand Down Expand Up @@ -474,8 +474,8 @@ The outputs are:

}

// grad_h_to_x should be defined here!;
grad_v_init[index] = grad_h * grad_h_to_x;
// grad_h_next_to_v should be defined here!;
grad_v_init[index] = grad_h * grad_h_next_to_v;

}
}
Expand Down Expand Up @@ -560,8 +560,8 @@ Then we can print the full codes of the BPTT kernel of the IF neuron:

#include <cuda_fp16.h>
extern "C" __global__
void NeuronBPTTKernel_float_hard_reset_nodetach_reset(
const int & numel, const int & N, const float * grad_spike_seq, const float * grad_v_seq, const float * h_seq, float * grad_x_seq, float * grad_v_init, float & v_th, float & v_reset
void IFNodeBPTTKernel_float_hard_reset_nodetach_reset(
const int & N, const float * grad_spike_seq, float * grad_v_init, const float * grad_v_seq, float * grad_x_seq, const float * h_seq, const int & numel, float & v_reset, float & v_th
)

{
Expand Down Expand Up @@ -598,8 +598,8 @@ Then we can print the full codes of the BPTT kernel of the IF neuron:

}

const float grad_h_to_x = 1.0f;
grad_v_init[index] = grad_h * grad_h_to_x;
const float grad_h_next_to_v = 1.0f;
grad_v_init[index] = grad_h * grad_h_next_to_v;

}
}
Expand Down

0 comments on commit 2941330

Please sign in to comment.