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

Function LaunchRowReduction

tensorflow/core/kernels/reduction_gpu_kernels.cu.h:719–760  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

717
718template <typename T, typename Op, typename OUT_T, typename IN_T>
719void LaunchRowReduction(OpKernelContext* ctx, OUT_T out, IN_T in, int num_rows,
720 int num_cols, Op op, T init,
721 const gpuStream_t& cu_stream) {
722 if (num_cols < 1024) {
723 const int threads_per_block = 128;
724 const int warps_per_block = threads_per_block / TF_RED_WARPSIZE;
725 int num_blocks = (num_rows + warps_per_block - 1) / warps_per_block;
726
727 TF_CHECK_OK(GpuLaunchKernel(RowReduceKernel<IN_T, OUT_T, Op>, num_blocks,
728 threads_per_block, 0, cu_stream, in, out,
729 num_rows, num_cols, op, init));
730 return;
731 }
732
733 // setup segment offsets with counting and transform iterator
734 RowOffset row_offset_op(num_cols);
735 gpuprim::CountingInputIterator<int> counting_iter(0);
736 gpuprim::TransformInputIterator<int, RowOffset,
737 gpuprim::CountingInputIterator<int>>
738 transform_iter(counting_iter, row_offset_op);
739
740 size_t temp_storage_bytes = 0;
741 auto reduce = [&](void* temp_storage_ptr) {
742 auto success = gpuprim::DeviceSegmentedReduce::Reduce(
743 temp_storage_ptr, temp_storage_bytes, in, out, num_rows, transform_iter,
744 transform_iter + 1, op, init, cu_stream);
745
746 OP_REQUIRES(ctx, success == 0,
747 errors::Internal("CUB segmented reduce error",
748 GpuGetErrorString(success)));
749 };
750
751 reduce(nullptr); // Get required amount of temp storage.
752
753 Tensor temp_storage;
754 OP_REQUIRES_OK(
755 ctx, ctx->allocate_temp(
756 DT_INT8, TensorShape({static_cast<int64>(temp_storage_bytes)}),
757 &temp_storage));
758
759 reduce(temp_storage.flat<int8_t>().data()); // Do reduction.
760}
761
762template <typename T, typename Op, typename OUT_T, typename IN_T>
763void LaunchColumnReduction_LTE16Cols(OpKernelContext* ctx, OUT_T out, IN_T in,

Callers 1

ReduceImplFunction · 0.85

Calls 7

InternalFunction · 0.85
GpuGetErrorStringFunction · 0.85
GpuLaunchKernelFunction · 0.50
ReduceFunction · 0.50
TensorShapeClass · 0.50
allocate_tempMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected