"Fossies" - the Fresh Open Source Software Archive

Member "rspamd-1.7.3/contrib/torch/nn/lib/THNN/generic/Abs.c" (10 Apr 2018, 664 Bytes) of package /linux/misc/rspamd-1.7.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Abs.c" see the Fossies "Dox" file reference documentation.

    1 #ifndef TH_GENERIC_FILE
    2 #define TH_GENERIC_FILE "generic/Abs.c"
    3 #else
    4 
    5 void THNN_(Abs_updateOutput)(
    6           THNNState *state,
    7           THTensor *input,
    8           THTensor *output)
    9 {
   10   THTensor_(resizeAs)(output, input);
   11   THTensor_(abs)(output, input);
   12 }
   13 
   14 void THNN_(Abs_updateGradInput)(
   15           THNNState *state,
   16           THTensor *input,
   17           THTensor *gradOutput,
   18           THTensor *gradInput)
   19 {
   20   THNN_CHECK_NELEMENT(input, gradOutput);
   21   THTensor_(resizeAs)(gradInput, input);
   22   TH_TENSOR_APPLY3(real, gradInput, real, gradOutput, real, input,
   23     real z = *input_data;
   24     *gradInput_data = *gradOutput_data * (z >= 0 ? 1 : -1);
   25   );
   26 }
   27 
   28 #endif