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.

BroadcastShapeLink.py 992 B

5 years ago
12345678910111213141516171819202122232425
  1. from __future__ import absolute_import
  2. import ctypes
  3. from .._base import _LIB
  4. from .. import ndarray as _nd
  5. def broadcast_shape(in_arr, out_arr, add_axes=None, stream=None):
  6. # deprecated, only used in tests
  7. assert isinstance(in_arr, _nd.NDArray)
  8. assert isinstance(out_arr, _nd.NDArray)
  9. if add_axes is not None:
  10. pointer_func = ctypes.c_int * len(add_axes)
  11. pointer = pointer_func(*list(add_axes))
  12. _LIB.DLGpuBroadcastShape(in_arr.handle, out_arr.handle,
  13. pointer if add_axes else None, stream.handle if stream else None)
  14. def broadcast_shape_simple(in_arr, out_arr, out_strides, in_dims, stream=None):
  15. assert isinstance(in_arr, _nd.NDArray)
  16. assert isinstance(out_arr, _nd.NDArray)
  17. assert isinstance(out_strides, _nd.NDArray)
  18. assert isinstance(in_dims, _nd.NDArray)
  19. _LIB.DLGpuBroadcastShapeSimple(
  20. in_arr.handle, out_arr.handle, out_strides.handle, in_dims.handle, stream.handle if stream else None)