Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions python/paddle/fluid/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,19 +1160,22 @@ def grad_var_name(var_name):

def convert_np_dtype_to_dtype_(np_dtype):
"""
Convert the data type in numpy to the data type in Paddle
Convert the data type in numpy to the data type in Paddle.

Args:
np_dtype(np.dtype): the data type in numpy.
np_dtype (np.dtype|str): The data type in numpy or valid data type
string.

Returns:
core.VarDesc.VarType: the data type in Paddle.
core.VarDesc.VarType: The data type in Paddle.

"""
if np_dtype == "bfloat16":
# Convert the data type string to numpy data type.
if isinstance(np_dtype, str) and np_dtype == "bfloat16":
dtype = np.uint16
else:
dtype = np.dtype(np_dtype)

if dtype == np.float32:
return core.VarDesc.VarType.FP32
elif dtype == np.float64:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def initTestCase(self):


class TestTrilTriuOpAPI(unittest.TestCase):
""" test case by using API and has -1 dimension
""" test case by using API and has -1 dimension
"""

def test_api(self):
Expand Down