Skip to content

Add static, dynamic and training tests for all tf.keras.layers - #3753

Merged
phoenix-meadowlark merged 5 commits into
iree-org:mainfrom
phoenix-meadowlark:keras-layers
Nov 6, 2020
Merged

phoenix-meadowlark merged 5 commits into
iree-org:mainfrom
phoenix-meadowlark:keras-layers

Conversation

@phoenix-meadowlark

@phoenix-meadowlark phoenix-meadowlark commented Nov 6, 2020 •

Copy link
Copy Markdown
Contributor

Additional changes:

  • _TfLiteFunctionWrapper
    • only interprets its output as a dict if the expected keys are provided. it's not really worth trying to write a general this-behaves-like-python wrapper for TFLite imo.
    • has special logic for dealing with keras/tflite eccentricities.
  • lstm_test.py and lstm_static_test.py are deleted in favor of layers_test.py.

Currently only settings close to the default for each layer are tested. This could be expanded out in the future in the form of multiple unittests for each bazel test.

This will clutter the coverage tabe page a fair bit, but I'm planning to restructure those pages soon to address this anyway. The coverage info is also interesting (e.g. Conv3D/Transpose is failing on iree_vmla, but passing on other IREE backends).

This change adds 850 test targets, 478 of which are passing and will run on the CI. They all complete in under 35 seconds on my machine, so the added time from the tests shouldn't be too large.

image

@phoenix-meadowlark phoenix-meadowlark added integrations/tensorflow TensorFlow model import and conversion integrations Relating to high-level frontend integrations labels Nov 6, 2020
@google-cla google-cla Bot added the cla: yes label Nov 6, 2020
@phoenix-meadowlark phoenix-meadowlark changed the title Adds static and dynamic tests for all tf.keras.layers Add static and dynamic tests for all tf.keras.layers Nov 6, 2020
'ZeroPadding3D': [CONV_3D_INPUT],
}

LAYER_TO_KWARGS = {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe a default_dict to avoid having to list all these ones that just take an empty dict again?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I decided to use dict() to explicitly document that we weren't modifying any of the layer's settings. It is pretty verbose though. Thoughts?

Comment on lines +223 to +224
if FLAGS.layer == 'MultiHeadAttention':
outputs = layer_class(**kwargs)(*inputs)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

:-/ Special-casing this here seems not great

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is a bug in their API :/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a link/TODO then? :-)

@silvasean silvasean left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! Thanks for systematizing this!

outputs = layer_class(**kwargs)(*inputs)
else:
outputs = layer_class(**kwargs)(inputs)
self.m = tf.keras.Model(inputs, outputs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it is better to create just a layer and then call it as layer.call(inputs, training)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried that first and it was incompatible with IREE (and I think TFLite too).

@phoenix-meadowlark phoenix-meadowlark changed the title Add static and dynamic tests for all tf.keras.layers Add static, dynamic and training tests for all tf.keras.layers Nov 6, 2020
@phoenix-meadowlark
phoenix-meadowlark merged commit ab4cb7c into iree-org:main Nov 6, 2020
# Create a wrapped keras layer.
inputs = normalize([get_input(shape) for shape in input_shapes])
if FLAGS.layer == 'MultiHeadAttention':
# TODO(meadowlark): Fix this if keras updates their API to be consistent.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I meant file a bug with Keras and link it here :-)

phoenix-meadowlark added a commit that referenced this pull request Nov 9, 2020
The "Tensorflow End to End Coverage" page has grown quite a
bit over the past few months, and #3753 exasperated that
significantly. This change splits the TensorFlow coverage
into four groups:

- TensorFlow Base APIs
- TensorFlow Keras Layers
- Language and Speech Models
- Vision Models

and stores them under a parent page like "Getting Started".

The "tensorflow" column is also removed from the table to 
reduce visual clutter, as it passes by definition.
@ScottTodd ScottTodd mentioned this pull request Nov 9, 2020
copybara-service Bot pushed a commit that referenced this pull request Nov 9, 2020
* 1ba69d9 Deduplicate flow.executable ops during Flow dialect transformation. (#3702)
* 848b893 Seperate tensorflow coverage into multiple pages (#3758)
* be8dd02 Merge pull request #3760 from google/benvanik-aot-windows-prework
* 6d83db8 Adding support for embedding debug symbols (pdb/dwarf/etc) in dylibs.
* 8a1347f Bumping tracy to disable vsync capture and expose the dbghelp lock.
* 4dc7064 Improving error messages in iree-run-module with invalid function names.
* 4d7805b Optimizations to reduce dispatch overhead. All of these will be fixed with the..
* d57efa3 Making IREE_CHECK_OK not double-evaluate. Prior to this it would run the expre..
* 10b400e Canonicalizing win32 paths prior to trying to open files. Useful in cases wher..
* f9c11f2 [spirv] Use addNestedPass<FuncOp>() for passes working on functions (#3745)
* ab4cb7c Add static, dynamic and training tests for all tf.keras.layers (#3753)
* aaf3377 Adopt pipeline-in-a-pass infra (#3741)
* 43b1d76 Create template for Bug Reports (#3755)
* d264a16 Remove unused deps from kws test (#3751)
* 0601682 Add 'deep_copy' to bazel to allow variable reuse (#3750)
* a70b1d1 Merge google -> main (#3749)

COPYBARA_INTEGRATE_REVIEW=#3762 from ScottTodd:main-to-google 1ba69d9
PiperOrigin-RevId: 341484363
ScottTodd added a commit that referenced this pull request Nov 9, 2020
* 1ba69d9 Deduplicate flow.executable ops during Flow dialect transformation. (#3702)
* 848b893 Seperate tensorflow coverage into multiple pages (#3758)
* be8dd02 Merge pull request #3760 from google/benvanik-aot-windows-prework
* 6d83db8 Adding support for embedding debug symbols (pdb/dwarf/etc) in dylibs.
* 8a1347f Bumping tracy to disable vsync capture and expose the dbghelp lock.
* 4dc7064 Improving error messages in iree-run-module with invalid function names.
* 4d7805b Optimizations to reduce dispatch overhead. All of these will be fixed with the..
* d57efa3 Making IREE_CHECK_OK not double-evaluate. Prior to this it would run the expre..
* 10b400e Canonicalizing win32 paths prior to trying to open files. Useful in cases wher..
* f9c11f2 [spirv] Use addNestedPass<FuncOp>() for passes working on functions (#3745)
* ab4cb7c Add static, dynamic and training tests for all tf.keras.layers (#3753)
* aaf3377 Adopt pipeline-in-a-pass infra (#3741)
* 43b1d76 Create template for Bug Reports (#3755)
* d264a16 Remove unused deps from kws test (#3751)
* 0601682 Add 'deep_copy' to bazel to allow variable reuse (#3750)
* a70b1d1 Merge google -> main (#3749)

COPYBARA_INTEGRATE_REVIEW=#3762 from ScottTodd:main-to-google 1ba69d9
PiperOrigin-RevId: 341484363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integrations/tensorflow TensorFlow model import and conversion integrations Relating to high-level frontend integrations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants