本文整理了Java中org.nd4j.linalg.factory.Nd4j.getConstantHandler()
方法的一些代码示例,展示了Nd4j.getConstantHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Nd4j.getConstantHandler()
方法的具体详情如下:
包路径:org.nd4j.linalg.factory.Nd4j
类名称:Nd4j
方法名:getConstantHandler
暂无
代码示例来源:origin: deeplearning4j/nd4j
extraz[i] = val;
extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);
return extraArgz;
} else if (dtype == DataBuffer.Type.DOUBLE) {
extraz[i] = val;
extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);
return extraArgz;
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
@Override
public DataBuffer getConstantBuffer(double[] array) {
return Nd4j.getConstantHandler().getConstantBuffer(array);
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
@Override
public DataBuffer getConstantBuffer(float[] array) {
return Nd4j.getConstantHandler().getConstantBuffer(array);
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
@Override
public DataBuffer moveToConstant(DataBuffer dataBuffer) {
Nd4j.getConstantHandler().moveToConstantSpace(dataBuffer);
return dataBuffer;
}
}
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
@Override
public DataBuffer moveToConstant(DataBuffer dataBuffer) {
Nd4j.getConstantHandler().moveToConstantSpace(dataBuffer);
return dataBuffer;
}
}
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
@Override
public DataBuffer getConstantBuffer(float[] array) {
return Nd4j.getConstantHandler().getConstantBuffer(array);
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
@Override
public DataBuffer getConstantBuffer(int[] array) {
return Nd4j.getConstantHandler().getConstantBuffer(array);
}
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
@Override
public DataBuffer getConstantBuffer(int[] array) {
return Nd4j.getConstantHandler().getConstantBuffer(array);
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
@Override
public DataBuffer getConstantBuffer(double[] array) {
return Nd4j.getConstantHandler().getConstantBuffer(array);
}
代码示例来源:origin: org.nd4j/nd4j-api
@Override
public DataBuffer extraArgsDataBuff() {
if (extraArgz != null)
return extraArgz;
if (extraArgs != null) {
DataBuffer.Type dtype = x != null ? x.data().dataType() : Nd4j.dataType();
if (dtype == DataBuffer.Type.FLOAT || dtype == DataBuffer.Type.HALF) {
float extraz[] = new float[extraArgs.length];
for (int i = 0; i < extraArgs.length; i++) {
Number arg = (Number) extraArgs[i];
float val = arg.floatValue();
extraz[i] = val;
}
extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);
return extraArgz;
} else if (dtype == DataBuffer.Type.DOUBLE) {
double extraz[] = new double[extraArgs.length];
for (int i = 0; i < extraArgs.length; i++) {
Number arg = (Number) extraArgs[i];
double val = arg.doubleValue();
extraz[i] = val;
}
extraArgz = Nd4j.getConstantHandler().getConstantBuffer(extraz);;
return extraArgz;
}
}
return null;
}
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
protected void prepareDelayedMemory(INDArray array) {
if (configuration.getMemoryModel() == Configuration.MemoryModel.DELAYED) {
AllocationPoint pointData = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
AllocationPoint pointShape = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
if (pointData.getAllocationStatus() != AllocationStatus.DEVICE)
prepareDelayedMemory(array.data());
if (pointShape.getAllocationStatus() == AllocationStatus.HOST) {
DataBuffer oShape = array.shapeInfoDataBuffer();
DataBuffer nShape = Nd4j.getConstantHandler().relocateConstantSpace(oShape);
if (nShape == oShape)
Nd4j.getConstantHandler().moveToConstantSpace(nShape);
((JCublasNDArray) array).setShapeInfoDataBuffer(nShape);
}
}
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
protected void prepareDelayedMemory(INDArray array) {
if (configuration.getMemoryModel() == Configuration.MemoryModel.DELAYED) {
AllocationPoint pointData = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
AllocationPoint pointShape = allocator.getAllocationPoint(array.shapeInfoDataBuffer());
if (pointData.getAllocationStatus() != AllocationStatus.DEVICE)
prepareDelayedMemory(array.data());
if (pointShape.getAllocationStatus() == AllocationStatus.HOST) {
DataBuffer oShape = array.shapeInfoDataBuffer();
DataBuffer nShape = Nd4j.getConstantHandler().relocateConstantSpace(oShape);
if (nShape == oShape)
Nd4j.getConstantHandler().moveToConstantSpace(nShape);
((JCublasNDArray) array).setShapeInfoDataBuffer(nShape);
}
}
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
/**
* Utility method, to associate INDArray with specific device (backend-specific)
*
* @param buffer
*/
@Override
public void touch(DataBuffer buffer) {
if (buffer == null)
return;
AllocationPoint point = AtomicAllocator.getInstance().getAllocationPoint(buffer);
if (point.isConstant()) {
Nd4j.getConstantHandler().relocateConstantSpace(buffer);
} else {
AtomicAllocator.getInstance().getMemoryHandler().relocateObject(buffer);
}
}
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
/**
* Utility method, to associate INDArray with specific device (backend-specific)
*
* @param buffer
*/
@Override
public void touch(DataBuffer buffer) {
if (buffer == null)
return;
AllocationPoint point = AtomicAllocator.getInstance().getAllocationPoint(buffer);
if (point.isConstant()) {
Nd4j.getConstantHandler().relocateConstantSpace(buffer);
} else {
AtomicAllocator.getInstance().getMemoryHandler().relocateObject(buffer);
}
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
Nd4j.getConstantHandler().moveToConstantSpace(buffer.getFirst());
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
Nd4j.getConstantHandler().moveToConstantSpace(buffer.getFirst());
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
Nd4j.getConstantHandler().moveToConstantSpace(buffer.getFirst());
代码示例来源:origin: org.nd4j/nd4j-cuda-7.5
@Override
public CudaContext prepareActionAllWrite(INDArray... operands) {
CudaContext context = (CudaContext) allocator.getDeviceContext().getContext();
int cId = allocator.getDeviceId();
for (INDArray operand : operands) {
if (operand == null)
continue;
Nd4j.getCompressor().autoDecompress(operand);
AllocationPoint pointData = allocator.getAllocationPoint(operand);
AllocationPoint pointShape = allocator.getAllocationPoint(operand.shapeInfoDataBuffer());
pointData.acquireLock();
if (pointData.getDeviceId() != cId && pointData.getDeviceId() >= 0) {
DataBuffer buffer = operand.data().originalDataBuffer() == null ? operand.data()
: operand.data().originalDataBuffer();
allocator.getMemoryHandler().relocateObject(buffer);
}
if (pointShape.getDeviceId() != cId && pointShape.getDeviceId() >= 0) {
((JCublasNDArray) operand).setShapeInfoDataBuffer(
Nd4j.getConstantHandler().relocateConstantSpace(operand.shapeInfoDataBuffer()));
}
prepareDelayedMemory(operand);
allocator.getAllocationPoint(operand).setCurrentContext(context);
}
return context;
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
@Override
public CudaContext prepareActionAllWrite(INDArray... operands) {
CudaContext context = (CudaContext) allocator.getDeviceContext().getContext();
int cId = allocator.getDeviceId();
for (INDArray operand : operands) {
if (operand == null)
continue;
Nd4j.getCompressor().autoDecompress(operand);
AllocationPoint pointData = allocator.getAllocationPoint(operand);
AllocationPoint pointShape = allocator.getAllocationPoint(operand.shapeInfoDataBuffer());
pointData.acquireLock();
if (pointData.getDeviceId() != cId && pointData.getDeviceId() >= 0) {
DataBuffer buffer = operand.data().originalDataBuffer() == null ? operand.data()
: operand.data().originalDataBuffer();
allocator.getMemoryHandler().relocateObject(buffer);
}
if (pointShape.getDeviceId() != cId && pointShape.getDeviceId() >= 0) {
((JCublasNDArray) operand).setShapeInfoDataBuffer(
Nd4j.getConstantHandler().relocateConstantSpace(operand.shapeInfoDataBuffer()));
}
prepareDelayedMemory(operand);
allocator.getAllocationPoint(operand).setCurrentContext(context);
}
return context;
}
代码示例来源:origin: org.nd4j/nd4j-cuda-10.0
DataBuffer dimensionBuffer = Nd4j.getConstantHandler().getConstantBuffer(dimensions);
pointers.setDimensions(allocator.getPointer(dimensionBuffer, context));
pointers.setDimensionsLength(dimensions.length);
内容来源于网络,如有侵权,请联系作者删除!