Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correcting the number of flop for MatMul #19792

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions tensorflow/python/kernel_tests/matmul_op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def testSimpleStatistics(self):
for op in g.get_operations():
flops = ops.get_stats_for_node_def(g, op.node_def, "flops").value
if op.name == "MatMul":
self.assertEqual(7200, flops)
self.assertEqual(6975, flops)

def testTransposedStatistics(self):
g = ops.Graph()
Expand All @@ -153,7 +153,7 @@ def testTransposedStatistics(self):
for op in g.get_operations():
flops = ops.get_stats_for_node_def(g, op.node_def, "flops").value
if op.name == "MatMul":
self.assertEqual(7200, flops)
self.assertEqual(6975, flops)


try:
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/ops/math_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@ def _calc_mat_mul_flops(graph, node):
output_shape = graph_util.tensor_shape_from_node_def_name(graph, node.name)
output_shape.assert_is_fully_defined()
output_count = np.prod(output_shape.as_list())
return ops.OpStats("flops", (k * output_count * 2))
return ops.OpStats("flops", ((2 * k - 1) * output_count))


def _as_indexed_slices(x, optimize=True):
Expand Down