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

Function BM_ConvFloatDepthwise

tensorflow/core/kernels/nn_ops_test.cc:501–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

499} // namespace
500
501static void BM_ConvFloatDepthwise(int iters, int batch, int rows, int cols,
502 int in_depth, int depth_multiplier,
503 int out_depth, int filter_rows,
504 int filter_cols, DEPTHWISE_CONV_OP op,
505 int num_threads, int stride, Padding padding,
506 bool use_gpu, const string& label) {
507 testing::StopTiming();
508 if (!IsGoogleCudaEnabled() && use_gpu) {
509 testing::SetLabel(
510 strings::StrCat("Skipping GPU test (no --config=cuda): ", label));
511 return;
512 }
513 testing::SetLabel(label);
514
515 // Set the number of threads
516 SessionOptions options;
517 options.config.set_intra_op_parallelism_threads(num_threads);
518
519 // We set up a graph for computing convolution.
520 GraphDef graph;
521
522 // For this, we need an input tensor and a filter tensor.
523 // Compute the output size.
524 int64 out_rows = 0, out_cols = 0, pad_rows = 0, pad_cols = 0;
525 TF_CHECK_OK(GetWindowedOutputSize(rows, filter_rows, stride, padding,
526 &out_rows, &pad_rows));
527 TF_CHECK_OK(GetWindowedOutputSize(cols, filter_cols, stride, padding,
528 &out_cols, &pad_cols));
529
530 int64 num_ops = 0;
531 if (op == DEPTHWISE_CONV_OP_FWD) {
532 // Counting the number of floating point operations (both MUL and ADD)
533 // Forward computation:
534 // BATCH x OUT_ROW X OUT_COL X FLTR_ROW X FLTR_COL X DEPTH_MULT X IN_DEPTH
535 // We multiply by two since there are multiplications and additions.
536 num_ops = static_cast<int64>(batch * out_rows * out_cols) *
537 static_cast<int64>(filter_rows * filter_cols) *
538 static_cast<int64>(in_depth * depth_multiplier) * 2;
539 } else {
540 // Backward computation: both input and filter backprop take the same
541 // amount of computation:
542 // BATCH x IN_ROW X IN_COL X FLTR_ROW X FLTR_COL X DEPTH_MULT X IN_DEPTH
543 // We multiply by two since there are multiplications and additions.
544 // We divide by stride squared to approximate the affect of decreasing
545 // number of bprop output points per bprop input point with increasing
546 // stride.
547 num_ops = (static_cast<int64>(batch * rows * cols) *
548 static_cast<int64>(filter_rows * filter_cols) *
549 static_cast<int64>(in_depth * depth_multiplier) * 2) /
550 (stride * stride);
551 }
552
553 // FIXME
554 SetConstOp("input", {batch, rows, cols, in_depth}, DT_FLOAT,
555 graph.add_node());
556 SetConstOp("depthwise_filter",
557 {filter_rows, filter_cols, in_depth, depth_multiplier}, DT_FLOAT,
558 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