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

Method get_gradient_for_data

dlib/cuda/cudnn_dlibapi.cpp:1420–1453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1418 }
1419
1420 void tensor_conv::get_gradient_for_data (
1421 const bool add_to_output,
1422 const tensor& gradient_input,
1423 const tensor& filters,
1424 tensor& data_gradient
1425 )
1426 {
1427 choose_backward_data_algorithm(gradient_input, data_gradient);
1428
1429 const float alpha = 1;
1430 const float beta = add_to_output ? 1 : 0;
1431
1432 // Since cudnnConvolutionBackwardData() is an asynchronous call, we need to hold a
1433 // reference to the workspace buffer so we can be sure it isn't reallocated
1434 // while the function is still executing on the device. But each time we come
1435 // here, we make sure to grab the latest workspace buffer so that, globally, we
1436 // minimize the number of such buffers.
1437 backward_data_workspace = device_global_buffer(backward_data_workspace_size_in_bytes);
1438
1439
1440 CHECK_CUDNN(cudnnConvolutionBackwardData(context(),
1441 &alpha,
1442 (const cudnnFilterDescriptor_t)filter_handle,
1443 filters.device(),
1444 descriptor(gradient_input),
1445 gradient_input.device(),
1446 (const cudnnConvolutionDescriptor_t)conv_handle,
1447 (cudnnConvolutionBwdDataAlgo_t)backward_data_algo,
1448 backward_data_workspace,
1449 backward_data_workspace_size_in_bytes,
1450 &beta,
1451 descriptor(data_gradient),
1452 data_gradient.device()));
1453 }
1454
1455 void tensor_conv::
1456 get_gradient_for_filters (

Callers 4

test_convFunction · 0.45
perform_testMethod · 0.45
backwardMethod · 0.45
forwardMethod · 0.45

Calls 4

device_global_bufferFunction · 0.85
descriptorFunction · 0.85
contextFunction · 0.70
deviceMethod · 0.45

Tested by 2

test_convFunction · 0.36
perform_testMethod · 0.36