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

Implement packed clipping op. #1412

Merged
merged 31 commits into from
Dec 4, 2018
Merged

Implement packed clipping op. #1412

merged 31 commits into from
Dec 4, 2018

Conversation

annxingyuan
Copy link
Collaborator

@annxingyuan annxingyuan commented Nov 27, 2018

This PR addresses tensorflow/tfjs#803

Changes

  • Added ClipPackedProgram that implements clipping for packed textures
  • Added ENV flag WEBGL_PACK_CLIP, defaults to false
  • Added ENV flag WEBGL_PACK, defaults to false, that turns all packing-related flags on or off
  • Turn off NaN checking if PROD flag is on
  • Support scalar sampling in packed ops
  • Partially support packed get${Var}AtOutCoords and broadcasting - broadcasting only occurs when the innermost dimensions are the same and the vector to be broadcast is rank 0 or 1.

PERF


For repository owners only:

Please remember to apply all applicable tags to your pull request.
Tags: FEATURE, BREAKING, BUG, PERF, DEV, DOC, SECURITY

For more info see: https://github.com/tensorflow/tfjs/blob/master/DEVELOPMENT.md


This change is Reviewable

@annxingyuan annxingyuan self-assigned this Nov 27, 2018
Copy link
Contributor

@nsthorat nsthorat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 9 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @annxingyuan, @nsthorat, and @dsmilkov)


src/kernels/webgl/shader_compiler.ts, line 325 at r2 (raw file):

} else {
  /*
  Previous NaN check '(val < 0.0 || 0.0 < val || val == 0.0) ? false : true'

use * on each line


src/kernels/webgl/shader_compiler.ts, line 335 at r2 (raw file):

    bool hasNaN(vec4 values) {
      return any(bvec4(
        (values.x < 1.0 || 0.0 < values.x || values.x == 0.0) ? false : true,

can you call isNaN for each of these?

Copy link
Collaborator Author

@annxingyuan annxingyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 1 approvals obtained (waiting on @dsmilkov)


src/kernels/webgl/shader_compiler.ts, line 325 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

use * on each line

Done


src/kernels/webgl/shader_compiler.ts, line 335 at r2 (raw file):

Previously, nsthorat (Nikhil Thorat) wrote…

can you call isNaN for each of these?

Done

@annxingyuan annxingyuan merged commit dce101e into master Dec 4, 2018
@annxingyuan annxingyuan deleted the pack_clip branch December 4, 2018 15:59
} else if (feature === 'WEBGL_LAZILY_UNPACK') {
return false;
return this.get('WEBGL_PACK');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor issue: might be useful to note that this won't work if trying to turn on packing by calling set('WEBGL_PACK', true) from application code; it is still required to call set('WEBGL_LAZILY_UNPACK', true) since tf-layers initialization evaluates ENV.get('EPSILON') before application code, and causes evaluating and setting WEBGL_LAZILY_UNPACK to false.
I'm aware that this should be done, properly, using URL query string parameters.

Call stack:
Environment.evaluateFeature (environment.ts:299)
Environment.get (environment.ts:270)
MathBackendWebGL.compileAndRun (backend_webgl.ts:1988)
MathBackendWebGL.abs (backend_webgl.ts:1396)
(anonymous) (backend_webgl.ts:2029)
(anonymous) (engine.ts:156)
Engine.scopedRun (engine.ts:167)
Engine.tidy (engine.ts:153)
Environment.tidy (environment.ts:186)
MathBackendWebGL.floatPrecision (backend_webgl.ts:2028)
Environment.evaluateFeature (environment.ts:368)
Environment.get (environment.ts:270)
(anonymous) (common.ts:15)
extendStatics (tf-layers.js:20)
(anonymous) (tf-layers.js:21)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @astojilj - that's a good point - could you create a separate PR for this change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @astojilj - that's a good point - could you create a separate PR for this change?

I reported this so that you are aware of it when testing. Otherwise, I'm not sure what would be the desired behavior - setting master switch WEBGL_PACK would override all previously set sub-flags?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants