MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / BM_ConvFloat

Function BM_ConvFloat

tensorflow/core/kernels/nn_ops_test.cc:106–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104} // namespace
105
106static void BM_ConvFloat(int iters, int batch, int rows, int cols, int in_depth,
107 int out_depth, int filter_rows, int filter_cols,
108 CONV_OP op, int num_threads, int stride,
109 Padding padding, bool use_gpu, DataType data_type,
110 const string& label) {
111 testing::StopTiming();
112 if (!IsGoogleCudaEnabled() && use_gpu) {
113 testing::SetLabel(
114 strings::StrCat("Skipping GPU test (no --config=cuda): ", label));
115 return;
116 }
117 testing::SetLabel(label);
118
119 // Set the number of threads
120 SessionOptions options;
121 options.config.set_intra_op_parallelism_threads(num_threads);
122
123 // We set up a graph for computing convolution.
124 GraphDef graph;
125
126 // For this, we need an input tensor and a filter tensor.
127 // Compute the output size.
128 int64 out_rows = 0, out_cols = 0, pad_rows = 0, pad_cols = 0;
129 TF_CHECK_OK(GetWindowedOutputSize(rows, filter_rows, stride, padding,
130 &out_rows, &pad_rows));
131 TF_CHECK_OK(GetWindowedOutputSize(cols, filter_cols, stride, padding,
132 &out_cols, &pad_cols));
133 // Counting the number of floating point operations (both MUL and ADD)
134 int64 num_ops = 0;
135 if (op == CONV_OP_FORWARD) {
136 // Forward computation:
137 // BATCH x OUT_ROW X OUT_COL X IN_DEPTH X PATCH_ROW X PATH_COL X OUT_DEPTH
138 // We multiply by two since there are multiplications and additions.
139 num_ops = static_cast<int64>(batch * in_depth * out_depth) *
140 static_cast<int64>(filter_rows * filter_cols) *
141 static_cast<int64>(out_rows * out_cols) * 2;
142 } else {
143 // Backward computation:
144 // BATCH x IN_ROW X IN_COL X IN_DEPTH X PATCH_ROW X PATCH_COL X OUT_DEPTH
145 // We multiply by two since there are multiplications and additions.
146 num_ops = static_cast<int64>(batch * in_depth * out_depth) *
147 static_cast<int64>(filter_rows * filter_cols) *
148 static_cast<int64>(rows * cols) * 2;
149 }
150
151 SetConstOp("input", {batch, rows, cols, in_depth}, data_type,
152 graph.add_node());
153 SetConstOp("filter", {filter_rows, filter_cols, in_depth, out_depth},
154 data_type, graph.add_node());
155 SetConstOp("output_backprop", {batch, out_rows, out_cols, out_depth},
156 data_type, graph.add_node());
157 SetConstSizesOp("input_sizes",
158 std::vector<int32>({batch, rows, cols, in_depth}),
159 graph.add_node());
160 SetConstSizesOp(
161 "filter_sizes",
162 std::vector<int32>({filter_rows, filter_cols, in_depth, out_depth}),
163 graph.add_node());

Callers

nothing calls this directly

Calls 15

StopTimingFunction · 0.85
SetLabelFunction · 0.85
SetConstOpFunction · 0.85
SetConstSizesOpFunction · 0.85
NodeDefBuilderClass · 0.85
ConvertGraphDefToGraphFunction · 0.85
UseRealTimeFunction · 0.85
StartTimingFunction · 0.85
ItemsProcessedFunction · 0.85
IsGoogleCudaEnabledFunction · 0.50
StrCatFunction · 0.50

Tested by

no test coverage detected