|
| 1 | +// Copyright (c) 2024 PaddlePaddle Authors. All Rights Reserved. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +#pragma once |
| 16 | + |
| 17 | +#include "paddle/phi/core/dense_tensor.h" |
| 18 | +#include "paddle/phi/core/device_context.h" |
| 19 | +#include "paddle/phi/core/selected_rows.h" |
| 20 | + |
| 21 | +namespace phi { |
| 22 | + |
| 23 | +template <typename T, typename Context> |
| 24 | +void LookupTableGradCUDAKernel(const Context& dev_ctx, |
| 25 | + const DenseTensor& w, |
| 26 | + const DenseTensor& ids_in, |
| 27 | + const DenseTensor& out_grad, |
| 28 | + bool is_sparse, |
| 29 | + bool is_distributed, |
| 30 | + int64_t padding_idx, |
| 31 | + bool remote_prefetch, |
| 32 | + const std::string& entry_config, |
| 33 | + bool is_test, |
| 34 | + const std::string& entry, |
| 35 | + const std::string& table_class, |
| 36 | + const std::vector<std::string>& table_names, |
| 37 | + int trainer_id, |
| 38 | + bool grad_inplace, |
| 39 | + const std::vector<std::string>& epmap, |
| 40 | + const std::vector<int64_t>& height_sections, |
| 41 | + DenseTensor* w_grad); |
| 42 | + |
| 43 | +template <typename T, typename Context> |
| 44 | +void LookupTableSparseGradCUDAKernel( |
| 45 | + const Context& dev_ctx, |
| 46 | + const DenseTensor& w, |
| 47 | + const DenseTensor& ids_in, |
| 48 | + const DenseTensor& out_grad, |
| 49 | + bool is_sparse, |
| 50 | + bool is_distributed, |
| 51 | + int64_t padding_idx, |
| 52 | + bool remote_prefetch, |
| 53 | + const std::string& entry_config, |
| 54 | + bool is_test, |
| 55 | + const std::string& entry, |
| 56 | + const std::string& table_class, |
| 57 | + const std::vector<std::string>& table_names, |
| 58 | + int trainer_id, |
| 59 | + bool grad_inplace, |
| 60 | + const std::vector<std::string>& epmap, |
| 61 | + const std::vector<int64_t>& height_sections, |
| 62 | + SelectedRows* w_grad); |
| 63 | + |
| 64 | +} // namespace phi |
0 commit comments