loadSampleGPU function

GPUTensor<Vector> loadSampleGPU(
  1. GPUTensor<Matrix> dataset,
  2. int sampleIndex,
  3. CommandBuffer tape, {
  4. GPUTensor<Vector>? outTensor,
})

Implementation

GPUTensor<Vector> loadSampleGPU(
    GPUTensor<Matrix> dataset, int sampleIndex, CommandBuffer tape,
    {GPUTensor<Vector>? outTensor}) {
  int cols = dataset.shape[1];

  List<int> outShape = <int>[cols];
  GPUTensor<Vector> out = outTensor ?? GPUTensor<Vector>.empty(outShape);

  tape.putInt(OP_LOAD_SAMPLE);
  tape.putString(dataset.id);
  tape.putString(out.id);
  tape.putInt(sampleIndex);

  out.creator = GPUNode(
    <GPUTensor>[dataset],
    (CommandBuffer bTape) {
      bTape.putInt(OP_STORE_SAMPLE);
      bTape.putString(out.gradId);
      bTape.putString(dataset.gradId);
      bTape.putInt(sampleIndex);
    },
    opName: 'loadSampleGPU',
  );

  return out;
}