Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Conversation

@dsmilkov
Copy link
Contributor

@dsmilkov dsmilkov commented Aug 17, 2017

This change is Reviewable

@dsmilkov
Copy link
Contributor Author

Review status: 0 of 39 files reviewed at latest revision, 2 unresolved discussions.


src/math/webgl/conv_gpu.ts, line 54 at r2 (raw file):

          float xR = xRCorner + wR;

          if (xR < 0.0 || xR > ${xRowsLimit}) {

decided to not use zeropadding since the shader is 15% slower than an if statement, as measured on the benchmark, and if statements are easier to read.


src/math/webgl/conv_gpu_test.ts, line 284 at r1 (raw file):

  });

  it('2x2x1 in, 1d out, 2x2 filter, 1 stride, zeropad = 1', () => {

this test is a duplicate of an earlier test, 3 tests before this.


Comments from Reviewable

@dsmilkov dsmilkov requested a review from nsthorat August 17, 2017 18:08
@nsthorat
Copy link
Contributor

:lgtm_strong:


Reviewed 10 of 20 files at r1, 28 of 29 files at r2.
Review status: 38 of 39 files reviewed at latest revision, 11 unresolved discussions.


demos/benchmarks/conv_gpu_benchmark.ts, line 40 at r2 (raw file):

  const program = new Conv2DProgram(
      inputShape, fieldSize, outputDepth, stride, zeroPad, true);

pull true out to a const


demos/benchmarks/conv_transpose_gpu_benchmark.ts, line 41 at r2 (raw file):

  const program = new Conv2DTransposeProgram(
      xShape, fieldSize, origInputDepth, origStride, origPad, false);

pull 'false' out to a const


demos/benchmarks/max_pool_gpu_benchmark.ts, line 28 at r2 (raw file):

export const MAX_POOL_BENCHMARK_TEST: BenchmarkTest = (size: number) => {
  return testMaxPool(size, false);

can you make false / true below a "const positions = ..."


src/math/math_gpu.ts, line 534 at r2 (raw file):

      origPad: number): Array3D {
    const maxPoolPositionsProgram =
        new Pool2DProgram(x.shape, fSize, origStride, origPad, 'max', true);

can you pull 'true' out to a variable


src/math/webgl/conv_backprop_gpu.ts, line 32 at r2 (raw file):

    const yNumRows = yShape[0];
    const yNumCols = yShape[1];
    const xRowsLimit = xShape[0] - 0.5;

if possible, use >= instead of subtracting 0.5


src/math/webgl/conv_gpu.ts, line 33 at r2 (raw file):

    this.params = [fieldSize, stride, pad, hasBias];
    const biasSnippet = hasBias ? 'dotProd += getBias(d2);' : '';
    const xRowsLimit = xShape[0] - 0.5;

qq why -0.5? can we just use a >= like in pool?


src/math/webgl/max_pool_backprop_gpu_test.ts, line 37 at r2 (raw file):

    const positionsProgram =
        new Pool2DProgram(x.shape, fSize, origStride, origPad, 'max', true);

pull true out to a variable


src/math/webgl/max_pool_positions_gpu_test.ts, line 34 at r2 (raw file):

    initializeGPU(gpgpu, textureManager);
    const program =
        new Pool2DProgram(xShape, fieldSize, stride, pad, 'max', true);

pull true out to a variable


src/math/webgl/shader_compiler.ts, line 19 at r2 (raw file):

export type ShapeInfo = {
  logicalShape: number[]; texShape: [number, number];

didn't we want to keep this as a comma so it doesn't force us to put these on the same line? if not, let's just be consistent with the type below


Comments from Reviewable

@dsmilkov
Copy link
Contributor Author

Review status: 29 of 39 files reviewed at latest revision, 9 unresolved discussions, some commit checks pending.


demos/benchmarks/conv_gpu_benchmark.ts, line 40 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

pull true out to a const

Done.


demos/benchmarks/conv_transpose_gpu_benchmark.ts, line 41 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

pull 'false' out to a const

Done.


demos/benchmarks/max_pool_gpu_benchmark.ts, line 28 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

can you make false / true below a "const positions = ..."

Done.


src/math/math_gpu.ts, line 534 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

can you pull 'true' out to a variable

Done.


src/math/webgl/conv_backprop_gpu.ts, line 32 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

if possible, use >= instead of subtracting 0.5

Done.


src/math/webgl/conv_gpu.ts, line 33 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

qq why -0.5? can we just use a >= like in pool?

Done.


src/math/webgl/max_pool_backprop_gpu_test.ts, line 37 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

pull true out to a variable

Done.


src/math/webgl/max_pool_positions_gpu_test.ts, line 34 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

pull true out to a variable

Done.


src/math/webgl/shader_compiler.ts, line 19 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

didn't we want to keep this as a comma so it doesn't force us to put these on the same line? if not, let's just be consistent with the type below

Ah, good catch. I started using formatOnSave in my vscode user settings. We can enable it in workspace settings if you feel like using it too). It saved me lots of time in this PR.


Comments from Reviewable

@dsmilkov dsmilkov merged commit 86c6188 into master Aug 18, 2017
@dsmilkov dsmilkov deleted the logical branch August 18, 2017 20:46
mnottheone pushed a commit to mnottheone/deeplearnjs that referenced this pull request Dec 1, 2018
* migrate addScaledMat and conv2d to logical sampling and improve shader compiler

* fix conv2d zero paddig and make the project build

* migrate rest of conv shaders to logical

* replace zero pad with if

* migrate pool ops

* address review comments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants