|
|
|
@ -37,30 +37,9 @@ using LoDTensor = framework::LoDTensor;
|
|
|
|
|
using SelectedRows = framework::SelectedRows;
|
|
|
|
|
using DDim = framework::DDim;
|
|
|
|
|
|
|
|
|
|
static size_t GetSectionIndex(int64_t id,
|
|
|
|
|
const std::vector<int64_t>& abs_sections) {
|
|
|
|
|
for (size_t i = 1; i < abs_sections.size(); ++i) {
|
|
|
|
|
if (id < abs_sections[i]) {
|
|
|
|
|
return i - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return abs_sections.size() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::vector<int64_t> ToAbsoluteSection(
|
|
|
|
|
const std::vector<int>& height_sections) {
|
|
|
|
|
std::vector<int64_t> abs_sections;
|
|
|
|
|
abs_sections.resize(height_sections.size());
|
|
|
|
|
abs_sections[0] = 0;
|
|
|
|
|
for (size_t i = 1; i < height_sections.size(); ++i) {
|
|
|
|
|
abs_sections[i] = height_sections[i - 1] + abs_sections[i - 1];
|
|
|
|
|
}
|
|
|
|
|
return abs_sections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static std::vector<std::vector<int64_t>> SplitIds(
|
|
|
|
|
const std::vector<int64_t>& ids_vector,
|
|
|
|
|
const std::vector<int>& height_section, framework::Scope* scope) {
|
|
|
|
|
const std::vector<int64_t>& height_section, framework::Scope* scope) {
|
|
|
|
|
std::set<int64_t> all_ids;
|
|
|
|
|
for (auto id : ids_vector) {
|
|
|
|
|
all_ids.insert(id);
|
|
|
|
@ -78,7 +57,7 @@ static std::vector<std::vector<int64_t>> SplitIds(
|
|
|
|
|
|
|
|
|
|
static void SplitIdsIntoMultipleVarsBySection(
|
|
|
|
|
const std::vector<std::string>& in_var_names,
|
|
|
|
|
const std::vector<int>& height_section,
|
|
|
|
|
const std::vector<int64_t>& height_section,
|
|
|
|
|
const std::vector<std::vector<int64_t>>& splited_ids,
|
|
|
|
|
framework::Scope* scope) {
|
|
|
|
|
PADDLE_ENFORCE_EQ(in_var_names.size(), height_section.size(), "");
|
|
|
|
@ -100,7 +79,7 @@ static void SplitIdsIntoMultipleVarsBySection(
|
|
|
|
|
static void MergeMultipleVarsIntoOneBySection(
|
|
|
|
|
const std::string& id_name, const std::vector<int64_t>& ids_vector,
|
|
|
|
|
const std::string& out_name, const std::vector<std::string>& out_var_names,
|
|
|
|
|
const std::vector<int>& height_section,
|
|
|
|
|
const std::vector<int64_t>& height_section,
|
|
|
|
|
const std::vector<std::vector<int64_t>>& splited_ids,
|
|
|
|
|
const framework::ExecutionContext& context, framework::Scope* scope,
|
|
|
|
|
platform::DeviceContext* actual_ctx) {
|
|
|
|
@ -177,7 +156,7 @@ static void MergeMultipleVarsIntoOneBySection(
|
|
|
|
|
void prefetch(const std::string& id_name, const std::string& out_name,
|
|
|
|
|
const std::vector<std::string>& table_names,
|
|
|
|
|
const std::vector<std::string>& epmap,
|
|
|
|
|
const std::vector<int>& height_sections,
|
|
|
|
|
const std::vector<int64_t>& height_sections,
|
|
|
|
|
const framework::ExecutionContext& context,
|
|
|
|
|
const framework::Scope& scope) {
|
|
|
|
|
framework::Scope* local_scope = scope.NewTmpScope();
|
|
|
|
|