org.nd4j.linalg.factory.Nd4j.getConstantHandler()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.nd4j.linalg.factory.Nd4j.getConstantHandler()方法的一些代码示例,展示了Nd4j.getConstantHandler()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.getConstantHandler()方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:getConstantHandler

Nd4j.getConstantHandler介绍

暂无

代码示例

代码示例来源:origin: deeplearning4j/nd4j

  1. extraz[i] = val;
  2. extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);
  3. return extraArgz;
  4. } else if (dtype == DataBuffer.Type.DOUBLE) {
  5. extraz[i] = val;
  6. extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);
  7. return extraArgz;

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. @Override
  2. public DataBuffer getConstantBuffer(double[] array) {
  3. return Nd4j.getConstantHandler().getConstantBuffer(array);
  4. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. @Override
  2. public DataBuffer getConstantBuffer(float[] array) {
  3. return Nd4j.getConstantHandler().getConstantBuffer(array);
  4. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. @Override
  2. public DataBuffer moveToConstant(DataBuffer dataBuffer) {
  3. Nd4j.getConstantHandler().moveToConstantSpace(dataBuffer);
  4. return dataBuffer;
  5. }
  6. }

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. @Override
  2. public DataBuffer moveToConstant(DataBuffer dataBuffer) {
  3. Nd4j.getConstantHandler().moveToConstantSpace(dataBuffer);
  4. return dataBuffer;
  5. }
  6. }

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. @Override
  2. public DataBuffer getConstantBuffer(float[] array) {
  3. return Nd4j.getConstantHandler().getConstantBuffer(array);
  4. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. @Override
  2. public DataBuffer getConstantBuffer(int[] array) {
  3. return Nd4j.getConstantHandler().getConstantBuffer(array);
  4. }

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. @Override
  2. public DataBuffer getConstantBuffer(int[] array) {
  3. return Nd4j.getConstantHandler().getConstantBuffer(array);
  4. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. @Override
  2. public DataBuffer getConstantBuffer(double[] array) {
  3. return Nd4j.getConstantHandler().getConstantBuffer(array);
  4. }

代码示例来源:origin: org.nd4j/nd4j-api

  1. @Override
  2. public DataBuffer extraArgsDataBuff() {
  3. if (extraArgz != null)
  4. return extraArgz;
  5. if (extraArgs != null) {
  6. DataBuffer.Type dtype = x != null ? x.data().dataType() : Nd4j.dataType();
  7. if (dtype == DataBuffer.Type.FLOAT || dtype == DataBuffer.Type.HALF) {
  8. float extraz[] = new float[extraArgs.length];
  9. for (int i = 0; i < extraArgs.length; i++) {
  10. Number arg = (Number) extraArgs[i];
  11. float val = arg.floatValue();
  12. extraz[i] = val;
  13. }
  14. extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);
  15. return extraArgz;
  16. } else if (dtype == DataBuffer.Type.DOUBLE) {
  17. double extraz[] = new double[extraArgs.length];
  18. for (int i = 0; i < extraArgs.length; i++) {
  19. Number arg = (Number) extraArgs[i];
  20. double val = arg.doubleValue();
  21. extraz[i] = val;
  22. }
  23. extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);;
  24. return extraArgz;
  25. }
  26. }
  27. return null;
  28. }

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. protected void prepareDelayedMemory(INDArray array) {
  2. if (configuration.getMemoryModel() == Configuration.MemoryModel.DELAYED) {
  3. AllocationPoint pointData = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
  4. AllocationPoint pointShape = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
  5. if (pointData.getAllocationStatus() != AllocationStatus.DEVICE)
  6. prepareDelayedMemory(array.data());
  7. if (pointShape.getAllocationStatus() == AllocationStatus.HOST) {
  8. DataBuffer oShape = array.shapeInfoDataBuffer();
  9. DataBuffer nShape = Nd4j.getConstantHandler().relocateConstantSpace(oShape);
  10. if (nShape == oShape)
  11. Nd4j.getConstantHandler().moveToConstantSpace(nShape);
  12. ((JCublasNDArray) array).setShapeInfoDataBuffer(nShape);
  13. }
  14. }
  15. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. protected void prepareDelayedMemory(INDArray array) {
  2. if (configuration.getMemoryModel() == Configuration.MemoryModel.DELAYED) {
  3. AllocationPoint pointData = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
  4. AllocationPoint pointShape = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
  5. if (pointData.getAllocationStatus() != AllocationStatus.DEVICE)
  6. prepareDelayedMemory(array.data());
  7. if (pointShape.getAllocationStatus() == AllocationStatus.HOST) {
  8. DataBuffer oShape = array.shapeInfoDataBuffer();
  9. DataBuffer nShape = Nd4j.getConstantHandler().relocateConstantSpace(oShape);
  10. if (nShape == oShape)
  11. Nd4j.getConstantHandler().moveToConstantSpace(nShape);
  12. ((JCublasNDArray) array).setShapeInfoDataBuffer(nShape);
  13. }
  14. }
  15. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. /**
  2. * Utility method, to associate INDArray with specific device (backend-specific)
  3. *
  4. * @param buffer
  5. */
  6. @Override
  7. public void touch(DataBuffer buffer) {
  8. if (buffer == null)
  9. return;
  10. AllocationPoint point = AtomicAllocator.getInstance().getAllocationPoint(buffer);
  11. if (point.isConstant()) {
  12. Nd4j.getConstantHandler().relocateConstantSpace(buffer);
  13. } else {
  14. AtomicAllocator.getInstance().getMemoryHandler().relocateObject(buffer);
  15. }
  16. }

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. /**
  2. * Utility method, to associate INDArray with specific device (backend-specific)
  3. *
  4. * @param buffer
  5. */
  6. @Override
  7. public void touch(DataBuffer buffer) {
  8. if (buffer == null)
  9. return;
  10. AllocationPoint point = AtomicAllocator.getInstance().getAllocationPoint(buffer);
  11. if (point.isConstant()) {
  12. Nd4j.getConstantHandler().relocateConstantSpace(buffer);
  13. } else {
  14. AtomicAllocator.getInstance().getMemoryHandler().relocateObject(buffer);
  15. }
  16. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. Nd4j.getConstantHandler().moveToConstantSpace(buffer.getFirst());

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. Nd4j.getConstantHandler().moveToConstantSpace(buffer.getFirst());

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. Nd4j.getConstantHandler().moveToConstantSpace(buffer.getFirst());

代码示例来源:origin: org.nd4j/nd4j-cuda-7.5

  1. @Override
  2. public CudaContext prepareActionAllWrite(INDArray... operands) {
  3. CudaContext context = (CudaContext) allocator.getDeviceContext().getContext();
  4. int cId = allocator.getDeviceId();
  5. for (INDArray operand : operands) {
  6. if (operand == null)
  7. continue;
  8. Nd4j.getCompressor().autoDecompress(operand);
  9. AllocationPoint pointData = allocator.getAllocationPoint(operand);
  10. AllocationPoint pointShape = allocator.getAllocationPoint(operand.shapeInfoDataBuffer());
  11. pointData.acquireLock();
  12. if (pointData.getDeviceId() != cId && pointData.getDeviceId() >= 0) {
  13. DataBuffer buffer = operand.data().originalDataBuffer() == null ? operand.data()
  14. : operand.data().originalDataBuffer();
  15. allocator.getMemoryHandler().relocateObject(buffer);
  16. }
  17. if (pointShape.getDeviceId() != cId && pointShape.getDeviceId() >= 0) {
  18. ((JCublasNDArray) operand).setShapeInfoDataBuffer(
  19. Nd4j.getConstantHandler().relocateConstantSpace(operand.shapeInfoDataBuffer()));
  20. }
  21. prepareDelayedMemory(operand);
  22. allocator.getAllocationPoint(operand).setCurrentContext(context);
  23. }
  24. return context;
  25. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. @Override
  2. public CudaContext prepareActionAllWrite(INDArray... operands) {
  3. CudaContext context = (CudaContext) allocator.getDeviceContext().getContext();
  4. int cId = allocator.getDeviceId();
  5. for (INDArray operand : operands) {
  6. if (operand == null)
  7. continue;
  8. Nd4j.getCompressor().autoDecompress(operand);
  9. AllocationPoint pointData = allocator.getAllocationPoint(operand);
  10. AllocationPoint pointShape = allocator.getAllocationPoint(operand.shapeInfoDataBuffer());
  11. pointData.acquireLock();
  12. if (pointData.getDeviceId() != cId && pointData.getDeviceId() >= 0) {
  13. DataBuffer buffer = operand.data().originalDataBuffer() == null ? operand.data()
  14. : operand.data().originalDataBuffer();
  15. allocator.getMemoryHandler().relocateObject(buffer);
  16. }
  17. if (pointShape.getDeviceId() != cId && pointShape.getDeviceId() >= 0) {
  18. ((JCublasNDArray) operand).setShapeInfoDataBuffer(
  19. Nd4j.getConstantHandler().relocateConstantSpace(operand.shapeInfoDataBuffer()));
  20. }
  21. prepareDelayedMemory(operand);
  22. allocator.getAllocationPoint(operand).setCurrentContext(context);
  23. }
  24. return context;
  25. }

代码示例来源:origin: org.nd4j/nd4j-cuda-10.0

  1. DataBuffer dimensionBuffer = Nd4j.getConstantHandler().getConstantBuffer(dimensions);
  2. pointers.setDimensions(allocator.getPointer(dimensionBuffer, context));
  3. pointers.setDimensionsLength(dimensions.length);

相关文章