Java Code Examples for org.bytedeco.javacpp.PointerPointer#put()

The following examples show how to use org.bytedeco.javacpp.PointerPointer#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Session.java    From java with Apache License 2.0 5 votes vote down vote up
private static void resolveHandles(String type, Pointer[] src, PointerPointer dst, int n) {
  if (src.length != n) {
    throw new IllegalArgumentException("expected " + n + ", got " + src.length + " " + type);
  }
  for (int i = 0; i < n; ++i) {
    if (src[i] == null || src[i].isNull()) {
      throw new IllegalStateException("invalid " + type + " (#" + i + " of " + n + ")");
    }
    dst.put(i, src[i]);
  }
}
 
Example 2
Source File: GraphOperationBuilder.java    From java with Apache License 2.0 5 votes vote down vote up
private static void setAttrTensorList(TF_OperationDescription handle, String name, TF_Tensor[] tensorHandles) {
  requireHandle(handle);

  try (PointerScope scope = new PointerScope()) {
    PointerPointer<TF_Tensor> tensors = new PointerPointer<TF_Tensor>(tensorHandles.length);
    for (int i = 0; i < tensorHandles.length; ++i) {
      requireTensor(tensorHandles[i]);
      tensors.put(i, tensorHandles[i]);
    }

    TF_Status status = TF_Status.newStatus();
    TF_SetAttrTensorList(handle, new BytePointer(name), tensors.position(0), tensorHandles.length, status);
    status.throwExceptionIfNotOK();
  }
}
 
Example 3
Source File: GraphOperationBuilder.java    From java with Apache License 2.0 5 votes vote down vote up
private static void setAttrShapeList(TF_OperationDescription handle, String name, long[] shapes, int[] numDims) {
  requireHandle(handle);

  try (PointerScope scope = new PointerScope()) {
    LongPointer shapesPointer = new LongPointer(shapes);
    PointerPointer<LongPointer> shapesPointers = new PointerPointer<LongPointer>(numDims.length);
    for (int i = 0; i < numDims.length; i++) {
      shapesPointers.put(i, shapesPointer);
      shapesPointer.position(shapesPointer.position() + numDims[i] * 8);
    }
    TF_SetAttrShapeList(handle, new BytePointer(name), shapesPointers, new IntPointer(numDims), numDims.length);
  }
}
 
Example 4
Source File: GraphOperationBuilder.java    From java with Apache License 2.0 5 votes vote down vote up
private static void setAttrStringList(TF_OperationDescription handle, String name, byte[][] value) {
  requireHandle(handle);

  try (PointerScope scope = new PointerScope()) {
    PointerPointer<BytePointer> valuePointers = new PointerPointer<BytePointer>(value.length);
    SizeTPointer lengths = new SizeTPointer(value.length);

    for (int i = 0; i < value.length; ++i) {
      valuePointers.put(i, new BytePointer(value[i]));
      lengths.put(i, value[i].length);
    }
    TF_SetAttrStringList(handle, new BytePointer(name), valuePointers, lengths, value.length);
  }
}
 
Example 5
Source File: EagerOperationBuilder.java    From java with Apache License 2.0 5 votes vote down vote up
private static void addInputList(TFE_Op opHandle, TFE_TensorHandle[] tensorHandles) {
  requireOp(opHandle);
  try (PointerScope scope = new PointerScope()) {
    PointerPointer<TFE_TensorHandle> tensorPointers = new PointerPointer<TFE_TensorHandle>(tensorHandles.length);
    for (int i = 0; i < tensorHandles.length; ++i) {
      requireTensorHandle(tensorHandles[i]);
      tensorPointers.put(i, tensorHandles[i]);
    }
    TF_Status status = TF_Status.newStatus();
    TFE_OpAddInputList(opHandle, tensorPointers, tensorHandles.length, status);
    status.throwExceptionIfNotOK();
  }
}
 
Example 6
Source File: EagerOperationBuilder.java    From java with Apache License 2.0 5 votes vote down vote up
private static void setAttrStringList(TFE_Op opHandle, String name, byte[][] value) {
  requireOp(opHandle);
  try (PointerScope scope = new PointerScope()) {
    PointerPointer<BytePointer> valuePointers = new PointerPointer<BytePointer>(value.length);
    SizeTPointer lengths = new SizeTPointer(value.length);

    for (int i = 0; i < value.length; ++i) {
      valuePointers.put(i, new BytePointer(value[i]));
      lengths.put(i, value[i].length);
    }
    TFE_OpSetAttrStringList(opHandle, name, valuePointers, lengths, value.length);
  }
}
 
Example 7
Source File: EagerOperationBuilder.java    From java with Apache License 2.0 5 votes vote down vote up
private static void setAttrShapeList(TFE_Op opHandle, String name, long[] shapes, int[] numDims) {
  requireOp(opHandle);
  try (PointerScope scope = new PointerScope()) {
    LongPointer shapesPointer = new LongPointer(shapes);
    PointerPointer<LongPointer> shapesPointers = new PointerPointer<LongPointer>(numDims.length);
    for (int i = 0; i < numDims.length; i++) {
      shapesPointers.put(i, shapesPointer);
      shapesPointer.position(shapesPointer.position() + numDims[i] * 8);
    }
    TF_Status status = TF_Status.newStatus();
    TFE_OpSetAttrShapeList(opHandle, new BytePointer(name), shapesPointers, new IntPointer(numDims),
                          numDims.length, status);
  }
}
 
Example 8
Source File: CudaNativeRandom.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Override
public PointerPointer getExtraPointers() {
    PointerPointer ptr = new PointerPointer(4);
    CudaContext context = (CudaContext) AtomicAllocator.getInstance().getDeviceContext().getContext();
    ptr.put(0, AtomicAllocator.getInstance().getHostPointer(stateBuffer));
    ptr.put(1, context.getOldStream());
    return ptr;
}