2 // Copyright (c) 2016 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 #include "batch_norm_grad_inst.h"
18 #include "primitive_gpu_base.h"
19 #include "implementation_map.h"
20 #include "error_handler.h"
21 #include "kernel_selector_helper.h"
22 #include "batch_norm_grad/batch_norm_grad_kernel_base.h"
23 #include "batch_norm_grad/batch_norm_grad_kernel_selector.h"
28 struct batch_norm_grad_gpu : typed_primitive_gpu_impl<batch_norm_grad>
30 using parent = typed_primitive_gpu_impl<batch_norm_grad>;
35 virtual kernel::kernel_arguments_data get_arguments(typed_primitive_inst<batch_norm_grad>& instance, int32_t) const override
37 kernel::kernel_arguments_data args;
39 args.inputs = { &instance.input_memory(0), &instance.input_memory(1), &instance.inv_variance_memory() };
40 args.output = &instance.output_memory();
47 static primitive_impl* create(const batch_norm_grad_node &arg)
49 auto norm_params = get_default_params<kernel_selector::batch_norm_grad_params>(arg);
50 auto norm_optional_params = get_default_optional_params<kernel_selector::batch_norm_grad_optional_params>(arg.get_program());
53 auto& kernel_selector = kernel_selector::batch_norm_grad_kernel_selector::Instance();
54 auto best_kernels = kernel_selector.GetBestKernels(norm_params, norm_optional_params);
56 CLDNN_ERROR_BOOL(arg.id(), "Best_kernel.empty()", best_kernels.empty(), "Cannot find a proper kernel with this arguments");
58 auto norm = new batch_norm_grad_gpu(arg, best_kernels[0]);
67 auto val_fw = batch_norm_grad_gpu::create;
69 implementation_map<batch_norm_grad>::add(std::make_tuple(engine_types::ocl, data_types::f32, format::yxfb), val_fw);
70 implementation_map<batch_norm_grad>::add(std::make_tuple(engine_types::ocl, data_types::f16, format::yxfb), val_fw);
71 implementation_map<batch_norm_grad>::add(std::make_tuple(engine_types::ocl, data_types::f32, format::bfyx), val_fw);
72 implementation_map<batch_norm_grad>::add(std::make_tuple(engine_types::ocl, data_types::f16, format::bfyx), val_fw);
73 implementation_map<batch_norm_grad>::add(std::make_tuple(engine_types::ocl, data_types::f32, format::byxf), val_fw);
74 implementation_map<batch_norm_grad>::add(std::make_tuple(engine_types::ocl, data_types::f16, format::byxf), val_fw);