You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ReluLink.py 681 B

5 years ago
1234567891011121314151617181920
  1. from __future__ import absolute_import
  2. import ctypes
  3. from .._base import _LIB
  4. from .. import ndarray as _nd
  5. def relu(in_arr, out_arr, stream=None):
  6. assert isinstance(in_arr, _nd.NDArray)
  7. assert isinstance(out_arr, _nd.NDArray)
  8. _LIB.DLGpuRelu(in_arr.handle, out_arr.handle,
  9. stream.handle if stream else None)
  10. def relu_gradient(in_arr, in_grad_arr, out_arr, stream=None):
  11. assert isinstance(in_arr, _nd.NDArray)
  12. assert isinstance(in_grad_arr, _nd.NDArray)
  13. assert isinstance(out_arr, _nd.NDArray)
  14. _LIB.DLGpuReluGradient(in_arr.handle, in_grad_arr.handle,
  15. out_arr.handle, stream.handle if stream else None)