Repository navigation
Centralize tf.math coverage and expand to all functions - #3826
Conversation
3df6a6b to
4c27ae4
Compare
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. |
|
|
||
| def configure_dtypes(base_config: Config, | ||
| dtypes: Sequence[tf.DType], | ||
| exported_name: str = None) -> Dict[str, Config]: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
|
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. |
Adds tests for the functions in the
tf.mathAPI, with dynamic and complex variants.To avoid adding another 1332 tests of
bazeloverhead 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:The following tests are deleted:
bool_test.pycomplex_test.pyfinite_test.pylogical_ops_test.pymath_test.pyandmath_dyn_test.pyare replaced byquantization_test.pyandquantization_dyn_test.py, since a fake quant test was added to them after the PR was made.Supporting changes:
tf.Tensors to be passed to traces. (Numpy's unchangeablefloat64default is cumbersome).set_minustobazel.(Sorry for the length of the PR. Most of it is
BUILDor rote configurations in python).