Skip to content

Commit 794c8ee

Browse files
committedFeb 16, 2022
Rename AtBlockExit to AtScopeExit. Remove redundant kmgr.Initialize.
Signed-off-by: Michał Zientkiewicz <mzient@gmail.com>
1 parent 94e73cc commit 794c8ee

File tree

11 files changed

+5
-13
lines changed

11 files changed

+5
-13
lines changed
 

‎dali/core/mm/default_resources.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ const std::shared_ptr<pinned_async_resource> &ShareDefaultResourceImpl<memory_ki
225225
if (!g_resources.pinned_async) {
226226
static CUDARTLoader init_cuda; // force initialization of CUDA before creating the resource
227227
g_resources.pinned_async = CreateDefaultPinnedResource();
228-
static auto cleanup = AtBlockExit([] {
228+
static auto cleanup = AtScopeExit([] {
229229
g_resources.ReleasePinned();
230230
});
231231
}
@@ -240,7 +240,7 @@ const std::shared_ptr<managed_async_resource> &ShareDefaultResourceImpl<memory_k
240240
if (!g_resources.managed) {
241241
static CUDARTLoader init_cuda; // force initialization of CUDA before creating the resource
242242
g_resources.managed = CreateDefaultManagedResource();
243-
static auto cleanup = AtBlockExit([] {
243+
static auto cleanup = AtScopeExit([] {
244244
g_resources.ReleaseManaged();
245245
});
246246
}
@@ -260,7 +260,7 @@ const std::shared_ptr<device_async_resource> &ShareDefaultDeviceResourceImpl(int
260260
DeviceGuard devg(device_id);
261261
static CUDARTLoader init_cuda; // force initialization of CUDA before creating the resource
262262
g_resources.device[device_id] = CreateDefaultDeviceResource();
263-
static auto cleanup = AtBlockExit([] {
263+
static auto cleanup = AtScopeExit([] {
264264
g_resources.ReleaseDevice();
265265
});
266266
}

‎dali/kernels/imgproc/jpeg/jpeg_distortion_gpu_test.cu

-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ class JpegDistortionTestGPU : public ::testing::TestWithParam<std::tuple<bool, b
108108
CUDAEvent start = CUDAEvent::CreateWithFlags(0);
109109
CUDAEvent end = CUDAEvent::CreateWithFlags(0);
110110

111-
kmgr_.Initialize<Kernel>();
112111
kmgr_.Resize<Kernel>(1);
113112

114113
KernelContext ctx;

‎dali/kernels/kernel_manager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class DLL_PUBLIC KernelManager {
191191
if (!context.scratchpad) {
192192
DynamicScratchpad scratchpad({}, AccessOrder(context.gpu.stream));
193193
context.scratchpad = &scratchpad;
194-
auto finally = AtBlockExit([&]() {
194+
auto finally = AtScopeExit([&]() {
195195
context.scratchpad = nullptr;
196196
});
197197
inst.get<Kernel>().Run(context, std::forward<OutInArgs>(out_in_args)...);

‎dali/kernels/signal/dct/dct_gpu_test.cc

-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ TEST_P(Dct1DGpuPerfTest, DISABLED_PerfTest) {
248248
KernelContext ctx;
249249
ctx.gpu.stream = 0;
250250
KernelManager kmgr;
251-
kmgr.Initialize<Kernel>();
252251
kmgr.Resize<Kernel>(1);
253252
CUDAEvent start = CUDAEvent::CreateWithFlags(0);
254253
CUDAEvent end = CUDAEvent::CreateWithFlags(0);

‎dali/operators/audio/mel_scale/mel_filter_bank.cc

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ bool MelFilterBank<CPUBackend>::SetupImpl(std::vector<OutputDesc> &output_desc,
7979
make_string("'f' axis not present in the layout. Got: `", layout, "`"));
8080
TYPE_SWITCH(input.type(), type2id, T, MEL_FBANK_SUPPORTED_TYPES, (
8181
using MelFilterBankKernel = kernels::audio::MelFilterBankCpu<T>;
82-
kmgr_.Initialize<MelFilterBankKernel>();
8382
kmgr_.Resize<MelFilterBankKernel>(nsamples);
8483
output_desc[0].type = type2id<T>::value;
8584
const auto in_view = view<const T>(input);

‎dali/operators/audio/mfcc/mfcc.cu

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ std::vector<OutputDesc> SetupKernel(kernels::KernelManager &kmgr, kernels::Kerne
5151
const TensorList<GPUBackend> &input,
5252
span<const MFCC<GPUBackend>::DctArgs> args, int axis) {
5353
using Kernel = kernels::signal::dct::Dct1DGpu<T>;
54-
kmgr.Initialize<Kernel>();
5554
kmgr.Resize<Kernel>(1);
5655
auto in_view = view<const T>(input);
5756
auto &req = kmgr.Setup<Kernel>(0, ctx, in_view, args, axis);

‎dali/operators/generic/erase/erase.cc

-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ bool EraseImplCpu<T, Dims>::SetupImpl(std::vector<OutputDesc> &output_desc,
190190

191191
args_ = detail::GetEraseArgs<T, Dims>(spec_, ws, shape, layout);
192192

193-
kmgr_.Initialize<EraseKernel>();
194193
kmgr_.Resize<EraseKernel>(nsamples);
195194
// the setup step is not necessary for this kernel (output and input shapes are the same)
196195

‎dali/operators/image/distortion/jpeg_compression_distortion_op_gpu.cu

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace dali {
2323
class JpegCompressionDistortionGPU : public JpegCompressionDistortion<GPUBackend> {
2424
public:
2525
explicit JpegCompressionDistortionGPU(const OpSpec &spec) : JpegCompressionDistortion(spec) {
26-
kmgr_.Initialize<JpegDistortionKernel>();
2726
kmgr_.Resize<JpegDistortionKernel>(1);
2827
}
2928

‎dali/operators/signal/decibel/to_decibels_op_cpu.cc

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ bool ToDecibels<CPUBackend>::SetupImpl(std::vector<OutputDesc> &output_desc,
5959

6060
TYPE_SWITCH(input.type(), type2id, T, (float), (
6161
using ToDbKernel = kernels::signal::ToDecibelsCpu<T>;
62-
kmgr_.Initialize<ToDbKernel>();
6362
kmgr_.Resize<ToDbKernel>(nsamples);
6463
output_desc[0].shape = in_shape;
6564
output_desc[0].type = type2id<T>::value;

‎dali/operators/signal/fft/power_spectrum.cc

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ bool PowerSpectrum<CPUBackend>::SetupImpl(std::vector<OutputDesc> &output_desc,
6969
using OutputType = float;
7070
VALUE_SWITCH(in_shape.sample_dim(), Dims, FFT_SUPPORTED_NDIMS, (
7171
using FftKernel = kernels::signal::fft::Fft1DCpu<OutputType, InputType, Dims>;
72-
kmgr_.Initialize<FftKernel>();
7372
kmgr_.Resize<FftKernel>(nsamples);
7473
output_desc[0].type = type2id<OutputType>::value;
7574
output_desc[0].shape.resize(nsamples, Dims);

‎include/dali/core/call_at_exit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct CallAtExit {
3535
} // namespace detail
3636

3737
template <typename Callable>
38-
detail::CallAtExit<Callable> AtBlockExit(Callable &&c) {
38+
detail::CallAtExit<Callable> AtScopeExit(Callable &&c) {
3939
return detail::CallAtExit<Callable>(std::forward<Callable>(c));
4040
}
4141

0 commit comments

Comments
 (0)
Please sign in to comment.