Skip to content

Commit

Permalink
Merge pull request #40 from jiaoxuewu/paddlebox
Browse files Browse the repository at this point in the history
merge paddlebox
  • Loading branch information
qingshui authored Jun 8, 2022
2 parents d741cb4 + 0f9e550 commit f140966
Show file tree
Hide file tree
Showing 10 changed files with 462 additions and 60 deletions.
32 changes: 17 additions & 15 deletions paddle/fluid/framework/fleet/box_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ void BoxWrapper::PullSparse(const paddle::platform::Place& place,
const std::vector<float*>& values,
const std::vector<int64_t>& slot_lengths,
const int hidden_size, const int expand_embed_dim,
const int skip_offset) {
const int skip_offset, bool expand_only) {
#define EMBEDX_CASE(i, ...) \
case i: { \
constexpr size_t EmbedxDim = i; \
Expand All @@ -425,33 +425,33 @@ void BoxWrapper::PullSparse(const paddle::platform::Place& place,
PullSparseCase< \
boxps::FeaturePullValueGpuShareEmbedding<EmbedxDim, ExpandDim>>( \
place, keys, values, slot_lengths, hidden_size, expand_embed_dim, \
skip_offset); \
skip_offset, expand_only); \
} else if (feature_type_ == static_cast<int>(boxps::FEATURE_PCOC)) { \
PullSparseCase<boxps::FeaturePullValueGpuPCOC<EmbedxDim, ExpandDim>>( \
place, keys, values, slot_lengths, hidden_size, expand_embed_dim, \
skip_offset); \
skip_offset, expand_only); \
} else if (feature_type_ == static_cast<int>(boxps::FEATURE_QUANT) || \
feature_type_ == static_cast<int>(boxps::FEATURE_SHOWCLK)) { \
PullSparseCase<boxps::FeaturePullValueGpuQuant<EmbedxDim, ExpandDim>>( \
place, keys, values, slot_lengths, hidden_size, expand_embed_dim, \
skip_offset); \
skip_offset, expand_only); \
} else if (feature_type_ == static_cast<int>(boxps::FEATURE_CONV)) { \
PullSparseCase<boxps::FeaturePullValueGpuConv<EmbedxDim, ExpandDim>>( \
place, keys, values, slot_lengths, hidden_size, expand_embed_dim, \
skip_offset); \
skip_offset, expand_only); \
} else if (feature_type_ == static_cast<int>(boxps::FEATURE_VARIABLE)) { \
PullSparseCase<boxps::FeatureVarPullValueGpu<EmbedxDim, ExpandDim>>( \
place, keys, values, slot_lengths, hidden_size, expand_embed_dim, \
skip_offset); \
skip_offset, expand_only); \
} else if (EmbedxDim == 0 && \
feature_type_ == static_cast<int>(boxps::FEATURE_ADAM)) { \
PullSparseCase<boxps::FeatureVarPullValueGpu<EmbedxDim, ExpandDim>>( \
place, keys, values, slot_lengths, hidden_size, expand_embed_dim, \
skip_offset); \
skip_offset, expand_only); \
} else { \
PullSparseCase<boxps::FeaturePullValueGpu<EmbedxDim, ExpandDim>>( \
place, keys, values, slot_lengths, hidden_size, expand_embed_dim, \
skip_offset); \
skip_offset, expand_only); \
} \
} break

Expand Down Expand Up @@ -489,7 +489,9 @@ void BoxWrapper::PushSparseGrad(const paddle::platform::Place& place,
const std::vector<int64_t>& slot_lengths,
const int hidden_size,
const int expand_embed_dim,
const int batch_size, const int skip_offset) {
const int batch_size,
const int skip_offset,
bool expand_only) {
#define EMBEDX_CASE(i, ...) \
case i: { \
constexpr size_t EmbedxDim = i; \
Expand All @@ -508,30 +510,30 @@ void BoxWrapper::PushSparseGrad(const paddle::platform::Place& place,
PushSparseGradCase< \
boxps::FeaturePushValueGpuShareEmbedding<EmbedxDim, ExpandDim>>( \
place, keys, grad_values, slot_lengths, hidden_size, \
expand_embed_dim, batch_size, skip_offset); \
expand_embed_dim, batch_size, skip_offset, expand_only); \
} else if (feature_type_ == static_cast<int>(boxps::FEATURE_PCOC)) { \
PushSparseGradCase< \
boxps::FeaturePushValueGpuPCOC<EmbedxDim, ExpandDim>>( \
place, keys, grad_values, slot_lengths, hidden_size, \
expand_embed_dim, batch_size, skip_offset); \
expand_embed_dim, batch_size, skip_offset, expand_only); \
} else if (feature_type_ == static_cast<int>(boxps::FEATURE_VARIABLE)) { \
PushSparseGradCase<boxps::FeatureVarPushValueGpu<EmbedxDim, ExpandDim>>( \
place, keys, grad_values, slot_lengths, hidden_size, \
expand_embed_dim, batch_size, skip_offset); \
expand_embed_dim, batch_size, skip_offset, expand_only); \
} else if (feature_type_ == static_cast<int>(boxps::FEATURE_CONV)) { \
PushSparseGradCase< \
boxps::FeaturePushValueGpuConv<EmbedxDim, ExpandDim>>( \
place, keys, grad_values, slot_lengths, hidden_size, \
expand_embed_dim, batch_size, skip_offset); \
expand_embed_dim, batch_size, skip_offset, expand_only); \
} else if (EmbedxDim == 0 && \
feature_type_ == static_cast<int>(boxps::FEATURE_ADAM)) { \
PushSparseGradCase<boxps::FeatureVarPushValueGpu<EmbedxDim, ExpandDim>>( \
place, keys, grad_values, slot_lengths, hidden_size, \
expand_embed_dim, batch_size, skip_offset); \
expand_embed_dim, batch_size, skip_offset, expand_only); \
} else { \
PushSparseGradCase<boxps::FeaturePushValueGpu<EmbedxDim, ExpandDim>>( \
place, keys, grad_values, slot_lengths, hidden_size, \
expand_embed_dim, batch_size, skip_offset); \
expand_embed_dim, batch_size, skip_offset, expand_only); \
} \
} break

Expand Down
Loading

0 comments on commit f140966

Please sign in to comment.