diff --git a/python/paddle/tensor/linalg.py b/python/paddle/tensor/linalg.py index b2455323c2b2cd841e41fbb9209a46159caffd51..7901379d9c793494228ad5ddf8e61c6d86d5ff2a 100644 --- a/python/paddle/tensor/linalg.py +++ b/python/paddle/tensor/linalg.py @@ -133,8 +133,11 @@ def matmul(x, y, transpose_x=False, transpose_y=False, name=None): # [10, 3, 5, 5] """ - op_type = 'matmul_v2' - if paddle.in_dynamic_mode(): + if in_dygraph_mode(): + return _C_ops.final_state_matmul(x, y, transpose_x, transpose_y) + + if _in_legacy_dygraph(): + op_type = 'matmul_v2' op = getattr(_C_ops, op_type) return op(x, y, 'trans_x', transpose_x, 'trans_y', transpose_y)