Skip to content

Centralize tf.math coverage and expand to all functions - #3826

Merged
phoenix-meadowlark merged 39 commits into
iree-org:mainfrom
phoenix-meadowlark:backspace
Nov 18, 2020
Merged

phoenix-meadowlark merged 39 commits into
iree-org:mainfrom
phoenix-meadowlark:backspace

Conversation

@phoenix-meadowlark

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

Copy link
Copy Markdown
Contributor

Adds tests for the functions in the tf.math API, with dynamic and complex variants.

To avoid adding another 1332 tests of bazel overhead to the CI while still generating coverage tables, I created two versions of the test suites: one that CI will run that detects any new errors, and one that creates a test for each function and backend. The tests that this change adds to the CI are:

//integrations/tensorflow/e2e/math:math_complex_tests_multiple__iree_llvmjit PASSED in 26.9s
//integrations/tensorflow/e2e/math:math_complex_tests_multiple__iree_vmla PASSED in 15.3s
//integrations/tensorflow/e2e/math:math_complex_tests_multiple__iree_vulkan PASSED in 72.1s
//integrations/tensorflow/e2e/math:math_complex_tests_multiple__tf       PASSED in 38.1s
//integrations/tensorflow/e2e/math:math_dynamic_dims_tests_multiple__iree_llvmjit PASSED in 7.9s
//integrations/tensorflow/e2e/math:math_dynamic_dims_tests_multiple__iree_vmla PASSED in 13.9s
//integrations/tensorflow/e2e/math:math_dynamic_dims_tests_multiple__iree_vulkan PASSED in 4.5s
//integrations/tensorflow/e2e/math:math_dynamic_dims_tests_multiple__tf  PASSED in 38.0s
//integrations/tensorflow/e2e/math:math_tests_multiple__iree_llvmjit     PASSED in 41.5s
//integrations/tensorflow/e2e/math:math_tests_multiple__iree_vmla        PASSED in 19.7s
//integrations/tensorflow/e2e/math:math_tests_multiple__iree_vulkan      PASSED in 106.6s
//integrations/tensorflow/e2e/math:math_tests_multiple__tf               PASSED in 38.2s
//integrations/tensorflow/e2e/math:math_tests_multiple__tflite           PASSED in 21.1s

The following tests are deleted:

  • bool_test.py
  • complex_test.py
  • finite_test.py
  • logical_ops_test.py

math_test.py and math_dyn_test.py are replaced by quantization_test.py and quantization_dyn_test.py, since a fake quant test was added to them after the PR was made.

Supporting changes:

  • Allow tf.Tensors to be passed to traces. (Numpy's unchangeable float64 default is cumbersome).
  • Add set_minus to bazel.
  • Expand support for input generation (e.g. uniform bools).

(Sorry for the length of the PR. Most of it is BUILD or rote configurations in python).

@phoenix-meadowlark phoenix-meadowlark added integrations/tensorflow TensorFlow model import and conversion integrations Relating to high-level frontend integrations labels Nov 13, 2020
@google-cla google-cla Bot added the cla: yes label Nov 13, 2020
@ScottTodd

Copy link
Copy Markdown
Member

The following tests can be deleted as a follow up:

  • bool_test.py
  • complex_test.py
  • finite_test.py
  • logical_ops_test.py
  • math_test.py

How about deleting them in this PR and updating the PR title to reflect that this expands and centralizes existing test coverage?

@phoenix-meadowlark

Copy link
Copy Markdown
Contributor Author

How about deleting them in this PR and updating the PR title to reflect that this expands and centralizes existing test coverage?

Sure! I was just hesitant to remove things until this was integrated successfully, but there's not much reason to worry.

@phoenix-meadowlark phoenix-meadowlark changed the title Add tests for tf.math functions Centeralize tf.math coverage and expand to all functions Nov 13, 2020

@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.

Awesome!

@phoenix-meadowlark phoenix-meadowlark changed the title Centeralize tf.math coverage and expand to all functions Centralize tf.math coverage and expand to all functions Nov 13, 2020
Comment thread integrations/tensorflow/e2e/math/BUILD Resolved
Comment thread integrations/tensorflow/e2e/math/BUILD Resolved

def configure_dtypes(base_config: Config,
dtypes: Sequence[tf.DType],
exported_name: str = None) -> Dict[str, Config]:

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.

This argument never appears to be used? It seems odd when coupled with the functionality that automatically prepends the function name to the dict keys when normalizing.

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.

The use case is was for something like this:

"func":
    join_dicts(
        configure_dtypes(Config(settings_1), dtypes, "settings_1"),
        configure_dtypes(Config(settings_2), dtypes, "settings_2"),
    ),

But since tf.math is fairly simple there wasn't ever a need to test multiple kwarg configurations. The new Config class supports this via:

"func": {
    "settings_1": Config(settings_1,... dtypes),
    "settings_2": Config(settings_2,... dtypes),
},

for real, imag in zip(args[::2], args[1::2]):
inputs.append(tf.complex(real, imag))
result = function(*inputs, **kwargs)
# Directly returning a complex number causes an error.

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.

TODO? Issue?

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'm unsure if this is done for a good reason or not. I mostly just followed what the few complex-number tests we had did. It makes sense from the perspective of serializable inputs and outputs through.

@phoenix-meadowlark

phoenix-meadowlark commented Nov 16, 2020 •

Copy link
Copy Markdown
Contributor Author

This change is dependent on #3854. Kokoro is using TensorFlow 2.4.0 and the coverage difference between 2.4.0 and 2.5.0 for TFLite is too great to ignore.

Edit: I added more robust failure logging to TFLite, so as long as it doesn't throw C++ fatal errors I should be able to disable the problematic tests on the CI in a TODO that references #3854 instead.

@phoenix-meadowlark
phoenix-meadowlark merged commit d557419 into iree-org:main Nov 18, 2020
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