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.

MultiplyConstLink.py 711 B

4 years ago
12345678910111213141516171819
  1. from __future__ import absolute_import
  2. import ctypes
  3. from .._base import _LIB
  4. from .. import ndarray as _nd
  5. def matrix_elementwise_multiply_by_const(in_mat, val, out_mat, stream=None):
  6. assert isinstance(in_mat, (_nd.NDArray, _nd.IndexedSlices))
  7. assert isinstance(out_mat, (_nd.NDArray, _nd.IndexedSlices))
  8. if isinstance(in_mat, _nd.NDArray):
  9. _LIB.DLGpuMatrixMultiplyByConst(
  10. in_mat.handle, ctypes.c_float(val), out_mat.handle, stream.handle if stream else None)
  11. else:
  12. # isinstance(in_mat, _nd.IndexedSlices)
  13. _LIB.DLGpuMatrixMultiplyByConst(
  14. in_mat.values.handle, ctypes.c_float(val), out_mat.values.handle, stream.handle if stream else None)