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

Function BM_LRNFloat

tensorflow/core/kernels/nn_ops_test.cc:735–791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

733BM_ConvFloatDepthwiseBk(32, 112, 112, 24, 1, 24, 3, 3, 1, SAME, conv14);
734
735static void BM_LRNFloat(int iters, int depth, int cols, int rows,
736 int batch_size, int range, int num_threads,
737 const string& label) {
738 tensorflow::testing::StopTiming();
739 std::unique_ptr<Device> device(
740 DeviceFactory::NewDevice("CPU", {}, "/job:a/replica:0/task:0"));
741
742 thread::ThreadPool threadpool(Env::Default(), "test", num_threads);
743 Eigen::ThreadPoolDevice eigen_cpu_device(threadpool.AsEigenThreadPool(),
744 num_threads);
745 device->set_eigen_cpu_device(&eigen_cpu_device);
746
747 gtl::InlinedVector<TensorValue, 4> inputs;
748 TensorShape shape({batch_size, rows, cols, depth});
749
750 Tensor input(DT_FLOAT, shape);
751 test::FillIota<float>(&input, 1.0);
752 inputs.push_back({nullptr, &input});
753
754 // Convolution op.
755 NodeDef lrn_node_def;
756 TF_CHECK_OK(NodeDefBuilder("lrn_op", "LRN")
757 .Input("input", 0, DT_FLOAT)
758 .Attr("depth_radius", range)
759 .Attr("bias", 1.0)
760 .Attr("alpha", 0.1)
761 .Attr("beta", 0.5)
762 .Finalize(&lrn_node_def));
763
764 Status status;
765 std::unique_ptr<OpKernel> op(CreateOpKernel(DEVICE_CPU, device.get(),
766 cpu_allocator(), lrn_node_def,
767 TF_GRAPH_DEF_VERSION, &status));
768 TF_CHECK_OK(status);
769
770 OpKernelContext::Params params;
771 params.device = device.get();
772 params.frame_iter = FrameAndIter(0, 0);
773 params.inputs = &inputs;
774 params.op_kernel = op.get();
775 std::vector<AllocatorAttributes> attrs;
776 test::SetOutputAttrs(&params, &attrs);
777
778 std::unique_ptr<OpKernelContext> context(new OpKernelContext(&params));
779
780 op->Compute(context.get());
781 testing::UseRealTime();
782 tensorflow::testing::StartTiming();
783 for (int i = 0; i < iters; ++i) {
784 delete context->release_output(0).tensor;
785 op->Compute(context.get());
786 }
787 tensorflow::testing::StopTiming();
788 testing::ItemsProcessed(context->mutable_output(0)->NumElements() * iters *
789 (2 * range + 1) * 2);
790 testing::SetLabel(label);
791}
792

Callers

nothing calls this directly

Calls 15

StopTimingFunction · 0.85
DefaultFunction · 0.85
NodeDefBuilderClass · 0.85
CreateOpKernelFunction · 0.85
cpu_allocatorFunction · 0.85
FrameAndIterClass · 0.85
SetOutputAttrsFunction · 0.85
UseRealTimeFunction · 0.85
StartTimingFunction · 0.85
ItemsProcessedFunction · 0.85
SetLabelFunction · 0.85
AsEigenThreadPoolMethod · 0.80

Tested by

no test coverage detected