sigmoid3DGPU function

GPUTensor<Tensor3D> sigmoid3DGPU(
  1. GPUTensor<Tensor3D> t,
  2. CommandBuffer tape
)

Implementation

GPUTensor<Tensor3D> sigmoid3DGPU(GPUTensor<Tensor3D> t, CommandBuffer tape) {
  int depth = t.shape[0];
  int height = t.shape[1];
  int width = t.shape[2];

  List<List<List<double>>> zeros = <List<List<double>>>[];
  for (int c = 0; c < depth; c = c + 1) {
    List<List<double>> channel = <List<double>>[];
    for (int h = 0; h < height; h = h + 1) {
      List<double> row = <double>[];
      for (int w = 0; w < width; w = w + 1) {
        row.add(0.0);
      }
      channel.add(row);
    }
    zeros.add(channel);
  }

  GPUTensor<Tensor3D> out = GPUTensor<Tensor3D>(zeros);

  tape.putInt(OP_SIGMOID);
  tape.putString(t.id);
  tape.putString(out.id);

  out.creator = GPUNode(
    <GPUTensor>[t],
        (CommandBuffer bTape) {
      bTape.putInt(OP_SIGMOID_BACKWARD);
      bTape.putString(out.id);
      bTape.putString('${out.id}_grad');
      bTape.putString('${t.id}_grad');
    },
    opName: 'sigmoid_3dGPU',
    cost: depth * height * width,
  );

  return out;
}