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.

AddElewiseLink.py 1.2 kB

4 years ago
12345678910111213141516171819202122232425262728293031
  1. from __future__ import absolute_import
  2. import ctypes
  3. from .._base import _LIB
  4. from .. import ndarray as _nd
  5. def matrix_elementwise_add(matA, matB, matC, lazy_input=False, stream=None):
  6. # deprecated
  7. assert isinstance(matA, _nd.NDArray)
  8. assert isinstance(matB, _nd.NDArray)
  9. assert isinstance(matC, _nd.NDArray)
  10. _LIB.DLGpuMatrixElementwiseAdd(matA.handle, matB.handle, matC.handle, ctypes.c_bool(
  11. lazy_input), stream.handle if stream else None)
  12. def matrix_elementwise_add_simple(matA, matB, matC, stream=None):
  13. assert isinstance(matA, _nd.NDArray)
  14. assert isinstance(matB, _nd.NDArray)
  15. assert isinstance(matC, _nd.NDArray)
  16. _LIB.DLGpuMatrixElementwiseAddSimple(
  17. matA.handle, matB.handle, matC.handle, stream.handle if stream else None)
  18. def matrix_elementwise_add_lazy(matA, matB, matC, gpu_buf, stream=None):
  19. assert isinstance(matA, _nd.NDArray)
  20. assert isinstance(matB, _nd.NDArray)
  21. assert isinstance(matC, _nd.NDArray)
  22. assert isinstance(gpu_buf, _nd.NDArray)
  23. _LIB.DLGpuMatrixElementwiseAddLazy(
  24. matA.handle, matB.handle, matC.handle, gpu_buf.handle, stream.handle if stream else None)