Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix segfault when attempting to convert string to float16.
To make sure this gets fixed, add test for converting string to any numeric type. PiperOrigin-RevId: 286650886 Change-Id: I81f770ec2bbd33a863e8057ce198c679912fa8e0
- Loading branch information
1 parent
b787df8
commit 5ac1b9e
Showing
3 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Copyright 2020 The TensorFlow Authors. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ============================================================================== | ||
| """Tests for tensorflow.python.framework.constant_op.""" | ||
|
|
||
| from __future__ import absolute_import | ||
| from __future__ import division | ||
| from __future__ import print_function | ||
|
|
||
| from absl.testing import parameterized | ||
|
|
||
| from tensorflow.python.framework import constant_op | ||
| from tensorflow.python.framework import dtypes | ||
| from tensorflow.python.framework import ops | ||
| from tensorflow.python.platform import test | ||
|
|
||
|
|
||
| class ConstantOpTest(test.TestCase, parameterized.TestCase): | ||
|
|
||
| @parameterized.parameters( | ||
| dtypes.bfloat16, | ||
| dtypes.complex128, | ||
| dtypes.complex64, | ||
| dtypes.double, | ||
| dtypes.float16, | ||
| dtypes.float32, | ||
| dtypes.float64, | ||
| dtypes.half, | ||
| dtypes.int16, | ||
| dtypes.int32, | ||
| dtypes.int64, | ||
| dtypes.int8, | ||
| dtypes.qint16, | ||
| dtypes.qint32, | ||
| dtypes.qint8, | ||
| dtypes.quint16, | ||
| dtypes.quint8, | ||
| dtypes.uint16, | ||
| dtypes.uint32, | ||
| dtypes.uint64, | ||
| dtypes.uint8, | ||
| ) | ||
| def test_convert_string_to_number(self, dtype): | ||
| with self.assertRaises(TypeError): | ||
| constant_op.constant("hello", dtype) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| ops.enable_eager_execution() | ||
| test.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters