• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2018 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15"""StatsOptions to configure stats aggregation options for `tf.data` pipelines.
16
17"""
18from __future__ import absolute_import
19from __future__ import division
20from __future__ import print_function
21
22from tensorflow.python.data.experimental.ops import stats_aggregator
23from tensorflow.python.data.util import options
24from tensorflow.python.util.tf_export import tf_export
25
26
27@tf_export("data.experimental.StatsOptions")
28class StatsOptions(options.OptionsBase):
29  """Represents options for collecting dataset stats using `StatsAggregator`.
30
31  You can set the stats options of a dataset through the `experimental_stats`
32  property of `tf.data.Options`; the property is an instance of
33  `tf.data.experimental.StatsOptions`. For example, to collect latency stats
34  on all dataset edges, use the following pattern:
35
36  ```python
37  aggregator = tf.data.experimental.StatsAggregator()
38
39  options = tf.data.Options()
40  options.experimental_stats.aggregator = aggregator
41  options.experimental_stats.latency_all_edges = True
42  dataset = dataset.with_options(options)
43  ```
44  """
45
46  aggregator = options.create_option(
47      name="aggregator",
48      ty=stats_aggregator.StatsAggregator,
49      docstring=
50      "Associates the given statistics aggregator with the dataset pipeline.")
51
52  prefix = options.create_option(
53      name="prefix",
54      ty=str,
55      docstring=
56      "Prefix to prepend all statistics recorded for the input `dataset` with.",
57      default_factory=lambda: "")
58
59  counter_prefix = options.create_option(
60      name="counter_prefix",
61      ty=str,
62      docstring="Prefix for the statistics recorded as counter.",
63      default_factory=lambda: "")
64
65  latency_all_edges = options.create_option(
66      name="latency_all_edges",
67      ty=bool,
68      docstring=
69      "Whether to add latency measurements on all edges. Defaults to False.")
70