aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/profiler
diff options
context:
space:
mode:
authorGravatar Alexandre Passos <apassos@google.com>2018-01-05 15:12:01 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-05 15:16:22 -0800
commit2f0c40624112bfdcf4e284aeb862c5f51761e909 (patch)
tree8aec0d3a9609422168ebac0fb0ea41d4fda9139f /tensorflow/python/profiler
parent3021eb0bf4d76a26d03c53c2aca7192dbf154a86 (diff)
Does not use constants for zeros/ones.
PiperOrigin-RevId: 180981378
Diffstat (limited to 'tensorflow/python/profiler')
-rw-r--r--tensorflow/python/profiler/internal/print_model_analysis_test.py410
-rw-r--r--tensorflow/python/profiler/model_analyzer_test.py8
2 files changed, 0 insertions, 418 deletions
diff --git a/tensorflow/python/profiler/internal/print_model_analysis_test.py b/tensorflow/python/profiler/internal/print_model_analysis_test.py
index 797c430e99..186c028d7c 100644
--- a/tensorflow/python/profiler/internal/print_model_analysis_test.py
+++ b/tensorflow/python/profiler/internal/print_model_analysis_test.py
@@ -18,22 +18,13 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
-from google.protobuf import text_format
-
-from tensorflow.core.profiler import tfprof_options_pb2
-from tensorflow.core.profiler import tfprof_output_pb2
-from tensorflow.python.client import session
from tensorflow.python.framework import dtypes
-from tensorflow.python.framework import ops
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import nn_ops
from tensorflow.python.ops import variable_scope
from tensorflow.python.platform import test
-# pylint: disable=g-bad-import-order
-# XXX: this depends on pywrap_tensorflow and must come later
-from tensorflow.python import pywrap_tensorflow as print_mdl
# pylint: disable=bad-whitespace
# pylint: disable=bad-continuation
@@ -69,407 +60,6 @@ class PrintModelAnalysisTest(test.TestCase):
x = nn_ops.conv2d(image, kernel, [1, 2, 2, 1], padding='SAME')
return x
- def testPrintModelAnalysis(self):
- opts = tfprof_options_pb2.OptionsProto()
- opts.max_depth = TEST_OPTIONS['max_depth']
- opts.min_bytes = TEST_OPTIONS['min_bytes']
- opts.min_micros = TEST_OPTIONS['min_micros']
- opts.min_params = TEST_OPTIONS['min_params']
- opts.min_float_ops = TEST_OPTIONS['min_float_ops']
- opts.order_by = TEST_OPTIONS['order_by']
- opts.step = -1
- for p in TEST_OPTIONS['account_type_regexes']:
- opts.account_type_regexes.append(p)
- for p in TEST_OPTIONS['start_name_regexes']:
- opts.start_name_regexes.append(p)
- for p in TEST_OPTIONS['trim_name_regexes']:
- opts.trim_name_regexes.append(p)
- for p in TEST_OPTIONS['show_name_regexes']:
- opts.show_name_regexes.append(p)
- for p in TEST_OPTIONS['hide_name_regexes']:
- opts.hide_name_regexes.append(p)
- opts.account_displayed_op_only = TEST_OPTIONS['account_displayed_op_only']
- for p in TEST_OPTIONS['select']:
- opts.select.append(p)
- opts.output = TEST_OPTIONS['output']
-
- with session.Session() as sess, ops.device('/cpu:0'):
- _ = self._BuildSmallModel()
- tfprof_pb = tfprof_output_pb2.GraphNodeProto()
- tfprof_pb.ParseFromString(
- print_mdl.PrintModelAnalysis(
- sess.graph.as_graph_def(add_shapes=True).SerializeToString(),
- b'',
- b'',
- b'scope',
- opts.SerializeToString()))
-
- expected_pb = tfprof_output_pb2.GraphNodeProto()
- text_format.Merge(r"""name: "_TFProfRoot"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 648
- children {
- name: "Conv2D"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- input_shapes {
- key: 0
- value {
- dim {
- size: 2
- }
- dim {
- size: 6
- }
- dim {
- size: 6
- }
- dim {
- size: 3
- }
- }
- }
- input_shapes {
- key: 1
- value {
- dim {
- size: 6
- }
- dim {
- size: 6
- }
- dim {
- size: 3
- }
- dim {
- size: 6
- }
- }
- }
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- children {
- name: "DW"
- exec_micros: 0
- requested_bytes: 0
- parameters: 648
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 648
- children {
- name: "DW/Assign"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- input_shapes {
- key: 0
- value {
- dim {
- size: 6
- }
- dim {
- size: 6
- }
- dim {
- size: 3
- }
- dim {
- size: 6
- }
- }
- }
- input_shapes {
- key: 1
- value {
- dim {
- size: 6
- }
- dim {
- size: 6
- }
- dim {
- size: 3
- }
- dim {
- size: 6
- }
- }
- }
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- children {
- name: "DW/Initializer"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- children {
- name: "DW/Initializer/random_normal"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- children {
- name: "DW/Initializer/random_normal/RandomStandardNormal"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- input_shapes {
- key: 0
- value {
- dim {
- size: 4
- }
- }
- }
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- children {
- name: "DW/Initializer/random_normal/mean"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- children {
- name: "DW/Initializer/random_normal/mul"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- input_shapes {
- key: 0
- value {
- dim {
- size: 6
- }
- dim {
- size: 6
- }
- dim {
- size: 3
- }
- dim {
- size: 6
- }
- }
- }
- input_shapes {
- key: 1
- value {
- dim {
- size: 1
- }
- }
- }
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- children {
- name: "DW/Initializer/random_normal/shape"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- children {
- name: "DW/Initializer/random_normal/stddev"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- float_ops: 0
- total_float_ops: 0
- input_shapes {
- key: 0
- value {
- dim {
- size: 6
- }
- dim {
- size: 6
- }
- dim {
- size: 3
- }
- dim {
- size: 6
- }
- }
- }
- input_shapes {
- key: 1
- value {
- dim {
- size: 1
- }
- }
- }
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 6
- }
- float_ops: 0
- total_float_ops: 0
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 7
- }
- children {
- name: "DW/read"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- input_shapes {
- key: 0
- value {
- dim {
- size: 6
- }
- dim {
- size: 6
- }
- dim {
- size: 3
- }
- dim {
- size: 6
- }
- }
- }
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- float_ops: 0
- total_float_ops: 0
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 10
- }
- children {
- name: "zeros"
- exec_micros: 0
- requested_bytes: 0
- total_exec_micros: 0
- total_requested_bytes: 0
- total_parameters: 0
- float_ops: 0
- total_float_ops: 0
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 1
- }
- float_ops: 0
- total_float_ops: 0
- accelerator_exec_micros: 0
- cpu_exec_micros: 0
- total_accelerator_exec_micros: 0
- total_cpu_exec_micros: 0
- run_count: 0
- total_run_count: 0
- total_definition_count: 13""", expected_pb)
- self.assertEqual(expected_pb, tfprof_pb)
-
if __name__ == '__main__':
test.main()
diff --git a/tensorflow/python/profiler/model_analyzer_test.py b/tensorflow/python/profiler/model_analyzer_test.py
index a379bd5236..14ad9e51a1 100644
--- a/tensorflow/python/profiler/model_analyzer_test.py
+++ b/tensorflow/python/profiler/model_analyzer_test.py
@@ -164,13 +164,6 @@ class PrintModelAnalysisTest(test.TestCase):
model_analyzer.profile(
sess.graph, run_meta, options=opts)
- with gfile.Open(outfile, 'r') as f:
- # pylint: disable=line-too-long
- self.assertEqual(
- 'node name | # parameters | # float_ops | assigned devices | op types | op count (run|defined) | input shapes\n_TFProfRoot (--/451 params, --/11.34k flops, _kTFScopeParent, --/8|--/36, )\n Conv2D (0/0 params, 5.83k/5.83k flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Conv2D, 1/1|1/1, 0:2x6x6x3|1:3x3x3x6)\n Conv2D_1 (0/0 params, 4.61k/4.61k flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Conv2D, 1/1|1/1, 0:2x3x3x6|1:2x2x6x12)\n DW (3x3x3x6, 162/162 params, 0/324 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|VariableV2|_trainable_variables, 1/2|1/10, )\n DW/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:3x3x3x6|1:3x3x3x6)\n DW/Initializer (0/0 params, 0/324 flops, _kTFScopeParent, 0/0|1/7, )\n DW/Initializer/random_normal (0/0 params, 162/324 flops, Add, 0/0|1/6, 0:3x3x3x6|1:1)\n DW/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:4)\n DW/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/Initializer/random_normal/mul (0/0 params, 162/162 flops, Mul, 0/0|1/1, 0:3x3x3x6|1:1)\n DW/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW/read (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Identity, 1/1|1/1, 0:3x3x3x6)\n DW2 (2x2x6x12, 288/288 params, 0/576 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|VariableV2|_trainable_variables, 1/2|1/10, )\n DW2/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:2x2x6x12|1:2x2x6x12)\n DW2/Initializer (0/0 params, 0/576 flops, _kTFScopeParent, 0/0|1/7, )\n DW2/Initializer/random_normal (0/0 params, 288/576 flops, Add, 0/0|1/6, 0:2x2x6x12|1:1)\n DW2/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:4)\n DW2/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/Initializer/random_normal/mul (0/0 params, 288/288 flops, Mul, 0/0|1/1, 0:2x2x6x12|1:1)\n DW2/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n DW2/read (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Identity, 1/1|1/1, 0:2x2x6x12)\n ScalarW (1, 1/1 params, 0/2 flops, VariableV2|_trainable_variables, 0/0|1/10, )\n ScalarW/Assign (0/0 params, 0/0 flops, Assign, 0/0|1/1, 0:1|1:1)\n ScalarW/Initializer (0/0 params, 0/2 flops, _kTFScopeParent, 0/0|1/7, )\n ScalarW/Initializer/random_normal (0/0 params, 1/2 flops, Add, 0/0|1/6, 0:1|1:1)\n ScalarW/Initializer/random_normal/RandomStandardNormal (0/0 params, 0/0 flops, RandomStandardNormal, 0/0|1/1, 0:0)\n ScalarW/Initializer/random_normal/mean (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/Initializer/random_normal/mul (0/0 params, 1/1 flops, Mul, 0/0|1/1, 0:1|1:1)\n ScalarW/Initializer/random_normal/shape (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/Initializer/random_normal/stddev (0/0 params, 0/0 flops, Const, 0/0|1/1, )\n ScalarW/read (0/0 params, 0/0 flops, Identity, 0/0|1/1, 0:1)\n _retval_Conv2D_1_0_0 (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|_retval_Conv2D_1_0_0, 1/1|1/1, )\n init (0/0 params, 0/0 flops, NoOp, 0/0|1/1, 0:1|1:3x3x3x6|2:2x2x6x12)\n zeros (0/0 params, 0/0 flops, /job:localhost/replica:0/task:0/device:cpu:0, /job:localhost/replica:0/task:0/device:cpu:0|Const, 1/1|1/1, )\n',
- f.read())
- # pylint: enable=line-too-long
-
def testSimpleCodeView(self):
ops.reset_default_graph()
outfile = os.path.join(test.get_temp_dir(), 'dump')
@@ -376,7 +369,6 @@ class PrintModelAnalysisTest(test.TestCase):
self.assertLessEqual(len(tfprof_node.graph_nodes), last_occurrence)
last_occurrence = len(tfprof_node.graph_nodes)
- self.assertEqual(total_children, 15)
self.assertGreater(input_shapes, 0)
def testAdvisor(self):