MCPcopy Create free account
hub / github.com/davisking/dlib / softmax_all_gradient

Function softmax_all_gradient

dlib/cuda/cudnn_dlibapi.cpp:1842–1867  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1840
1841
1842 void softmax_all_gradient (
1843 tensor& grad,
1844 const tensor& dest,
1845 const tensor& gradient_input
1846 )
1847 {
1848 DLIB_CASSERT(
1849 have_same_dimensions(dest,gradient_input) == true &&
1850 have_same_dimensions(dest,grad) == true );
1851 if (dest.size() == 0)
1852 return;
1853
1854 const float alpha = 1;
1855 const float beta = is_same_object(grad,gradient_input) ? 0 : 1;
1856 CHECK_CUDNN(cudnnSoftmaxBackward(context(),
1857 CUDNN_SOFTMAX_ACCURATE,
1858 CUDNN_SOFTMAX_MODE_INSTANCE,
1859 &alpha,
1860 descriptor(dest),
1861 dest.device(),
1862 descriptor(gradient_input),
1863 gradient_input.device(),
1864 &beta,
1865 descriptor(grad),
1866 grad.device()));
1867 }
1868
1869 // ------------------------------------------------------------------------------------
1870 // ------------------------------------------------------------------------------------

Callers

nothing calls this directly

Calls 6

descriptorFunction · 0.85
have_same_dimensionsFunction · 0.70
contextFunction · 0.70
is_same_objectFunction · 0.50
sizeMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected