Browse Source

Fix code check 2.0 issue

r1.7
ZPaC 4 years ago
parent
commit
42bdf2bc5b
18 changed files with 55 additions and 43 deletions
  1. +1
    -1
      mindspore/ccsrc/distributed/constants.h
  2. +1
    -1
      mindspore/ccsrc/plugin/device/cpu/hal/hardware/mpi_collective_comm_lib.h
  3. +1
    -1
      mindspore/ccsrc/plugin/device/cpu/hal/hardware/mpi_communication_group.h
  4. +1
    -1
      mindspore/ccsrc/plugin/device/cpu/hal/hardware/ms_collective_comm_lib.h
  5. +2
    -1
      mindspore/ccsrc/plugin/device/cpu/kernel/ps/embedding_look_up_ps_kernel.cc
  6. +6
    -6
      mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_adam_ps_kernel.cc
  7. +5
    -0
      mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_adam_ps_kernel.h
  8. +6
    -6
      mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_ftrl_ps_kernel.cc
  9. +5
    -0
      mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_ftrl_ps_kernel.h
  10. +6
    -6
      mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_lazy_adam_ps_kernel.cc
  11. +5
    -0
      mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_lazy_adam_ps_kernel.h
  12. +2
    -2
      mindspore/ccsrc/plugin/device/gpu/hal/device/distribution/collective_fake_init.cc
  13. +1
    -1
      mindspore/ccsrc/plugin/device/gpu/hal/hardware/nvidia_collective_comm_lib.h
  14. +0
    -1
      mindspore/ccsrc/plugin/device/gpu/kernel/nccl/nccl_collective_gpu_kernel.cc
  15. +0
    -5
      mindspore/ccsrc/ps/constants.h
  16. +4
    -2
      mindspore/ccsrc/ps/ps_cache/embedding_hash_map.h
  17. +1
    -1
      mindspore/ccsrc/ps/ps_cache/ps_cache_basic.h
  18. +8
    -8
      mindspore/ccsrc/runtime/collective/communication_group.h

+ 1
- 1
mindspore/ccsrc/distributed/constants.h View File

@@ -50,7 +50,7 @@ constexpr uint32_t kDefaultFinishTimeout = 30;

// This macro the current timestamp in milliseconds.
#define CURRENT_TIMESTAMP_MILLI \
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()))
} // namespace distributed
} // namespace mindspore
#endif // MINDSPORE_CCSRC_DISTRIBUTED_CONSTANTS_H_

+ 1
- 1
mindspore/ccsrc/plugin/device/cpu/hal/hardware/mpi_collective_comm_lib.h View File

@@ -57,7 +57,7 @@ class EXPORT_MPI_WRAPPER MPICollectiveCommLib : public CollectiveCommunicationLi
return instance;
}

bool Initialize(uint32_t global_rank = UINT32_MAX, uint32_t global_rank_size = UINT32_MAX) override;
bool Initialize(uint32_t global_rank, uint32_t global_rank_size) override;

// Override creating method. Reuse destroying method in base class CollectiveCommunicationLib.
bool CreateCommunicationGroup(const std::string &group_name, const std::vector<uint32_t> &group_ranks) override;


+ 1
- 1
mindspore/ccsrc/plugin/device/cpu/hal/hardware/mpi_communication_group.h View File

@@ -34,7 +34,7 @@ class MPICommunicationGroup : public CommunicationGroup {

~MPICommunicationGroup() override = default;

bool Initialize(void *root_info) override { return true; }
bool Initialize(void *) override { return true; }
bool Finalize() override;

// The OpenMPI groups should be created from the world group.


+ 1
- 1
mindspore/ccsrc/plugin/device/cpu/hal/hardware/ms_collective_comm_lib.h View File

@@ -41,7 +41,7 @@ class MsCollectiveCommLib : public CollectiveCommunicationLib {
return instance;
}

bool Initialize(uint32_t global_rank = UINT32_MAX, uint32_t global_rank_size = UINT32_MAX) override;
bool Initialize(uint32_t global_rank, uint32_t global_rank_size) override;

bool CreateCommunicationGroup(const std::string &group_name, const std::vector<uint32_t> &group_ranks) override;



+ 2
- 1
mindspore/ccsrc/plugin/device/cpu/kernel/ps/embedding_look_up_ps_kernel.cc View File

@@ -51,7 +51,8 @@ void EmbeddingLookUpPSKernelMod::InitKernel(
for (auto shape : indices_shape) {
indices_lens_ = indices_lens_ * shape;
}
auto output_shape = *(shape_vec[2]);
size_t output_index = 2;
auto output_shape = *(shape_vec[output_index]);

int64_t offset = 0;
for (size_t i = 0; i < rank_id_; i++) {


+ 6
- 6
mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_adam_ps_kernel.cc View File

@@ -33,11 +33,11 @@ void SparseApplyAdamPSKernelMod::InitKernel(
if (shape_vec.size() < kSparseApplyAdamPSInputsShapeSize) {
MS_LOG(EXCEPTION) << "SparseApplyAdamPSKernelMod needs 10 input shapes, but got " << shape_vec.size();
}
std::vector<size_t> &var_shape = *(shape_vec[0]);
std::vector<size_t> &m_shape = *(shape_vec[1]);
std::vector<size_t> &v_shape = *(shape_vec[2]);
const std::vector<size_t> &grad_shape = *(shape_vec[9]);
const std::vector<size_t> &indices_shape = *(shape_vec[10]);
std::vector<size_t> &var_shape = *(shape_vec[var_index_]);
std::vector<size_t> &m_shape = *(shape_vec[m_index_]);
std::vector<size_t> &v_shape = *(shape_vec[v_index_]);
const std::vector<size_t> &grad_shape = *(shape_vec[grad_index_]);
const std::vector<size_t> &indices_shape = *(shape_vec[indices_index_]);

Shard(&var_shape, 0);
Shard(&m_shape, 0);
@@ -93,7 +93,7 @@ void SparseApplyAdamPSKernelMod::ReInit(const std::vector<AddressPtr> &inputs) {
MS_LOG(EXCEPTION) << "Input numbers should not less to " << kSparseApplyAdamPSInputsShapeSize << ", but got "
<< inputs.size();
}
const auto &indices_addr = inputs[10];
const auto &indices_addr = inputs[indices_index_];
indices_size_ = indices_addr->size / sizeof(int);
workspace_size_list_[0] = indices_size_ * var_outer_dim_size_ * sizeof(float);
workspace_size_list_[1] = indices_size_ * sizeof(int);


+ 5
- 0
mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_adam_ps_kernel.h View File

@@ -44,6 +44,11 @@ class SparseApplyAdamPSKernelMod : public SparseApplyAdamCpuKernelMod, public PS

protected:
void ReInit(const std::vector<AddressPtr> &) override;
size_t var_index_{0};
size_t m_index_{1};
size_t v_index_{2};
size_t grad_index_{9};
size_t indices_index_{10};
};
} // namespace ps
} // namespace kernel


+ 6
- 6
mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_ftrl_ps_kernel.cc View File

@@ -31,11 +31,11 @@ void SparseApplyFtrlPSKernelMod::InitKernel(
MS_LOG(EXCEPTION) << "SparseApplyAdamPSKernelMod needs " << kSparseApplyFtrlPSInputSize << " input shapes, but got "
<< shape_vec.size();
}
std::vector<size_t> var_shape = *(shape_vec[0]);
std::vector<size_t> accum_shape = *(shape_vec[1]);
std::vector<size_t> linear_shape = *(shape_vec[2]);
std::vector<size_t> grad_shape = *(shape_vec[3]);
std::vector<size_t> indices_shape = *(shape_vec[4]);
std::vector<size_t> var_shape = *(shape_vec[var_index_]);
std::vector<size_t> accum_shape = *(shape_vec[accum_index_]);
std::vector<size_t> linear_shape = *(shape_vec[linear_index_]);
std::vector<size_t> grad_shape = *(shape_vec[grad_index_]);
std::vector<size_t> indices_shape = *(shape_vec[indices_index_]);

Shard(&var_shape, 0);
Shard(&accum_shape, 0);
@@ -104,7 +104,7 @@ void SparseApplyFtrlPSKernelMod::ReInit(const std::vector<AddressPtr> &inputs) {
MS_LOG(EXCEPTION) << "Input numbers should not be less than " << kSparseApplyFtrlPSInputSize << ", but got "
<< inputs.size();
}
const auto &indices_addr = inputs[4];
const auto &indices_addr = inputs[indices_index_];
indices_size_ = indices_addr->size / sizeof(int);
workspace_size_list_[0] = indices_size_ * var_outer_dim_size_ * sizeof(float) * worker_num_;
workspace_size_list_[1] = indices_size_ * sizeof(int) * worker_num_;


+ 5
- 0
mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_ftrl_ps_kernel.h View File

@@ -47,6 +47,11 @@ class SparseApplyFtrlPSKernelMod : public SparseApplyFtrlCpuKernelMod, public PS
protected:
void ReInit(const std::vector<AddressPtr> &) override;
float init_accum_{0.1};
size_t var_index_{0};
size_t accum_index_{1};
size_t linear_index_{2};
size_t grad_index_{3};
size_t indices_index_{4};
};
} // namespace ps
} // namespace kernel


+ 6
- 6
mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_lazy_adam_ps_kernel.cc View File

@@ -34,11 +34,11 @@ void SparseApplyLazyAdamPSKernelMod::InitKernel(
MS_LOG(EXCEPTION) << "SparseApplyLazyAdamPSKernelMod needs " << kSparseApplyLazyAdamPSInputsSize
<< " input shapes, but got " << shape_vec.size();
}
std::vector<size_t> &var_shape = *(shape_vec[0]);
std::vector<size_t> &m_shape = *(shape_vec[1]);
std::vector<size_t> &v_shape = *(shape_vec[2]);
const std::vector<size_t> &grad_shape = *(shape_vec[9]);
const std::vector<size_t> &indices_shape = *(shape_vec[10]);
std::vector<size_t> &var_shape = *(shape_vec[var_index_]);
std::vector<size_t> &m_shape = *(shape_vec[m_index_]);
std::vector<size_t> &v_shape = *(shape_vec[v_index_]);
const std::vector<size_t> &grad_shape = *(shape_vec[grad_index_]);
const std::vector<size_t> &indices_shape = *(shape_vec[indices_index_]);

Shard(&var_shape, 0);
Shard(&m_shape, 0);
@@ -94,7 +94,7 @@ void SparseApplyLazyAdamPSKernelMod::ReInit(const std::vector<AddressPtr> &input
MS_LOG(EXCEPTION) << "Input shape size should not be less than " << kSparseApplyLazyAdamPSInputsSize << ", but got "
<< inputs.size();
}
const auto &indices_addr = inputs[10];
const auto &indices_addr = inputs[indices_index_];
indices_size_ = indices_addr->size / sizeof(int);
workspace_size_list_[0] = indices_size_ * var_outer_dim_size_ * sizeof(float) * worker_num_;
workspace_size_list_[1] = indices_size_ * sizeof(int) * worker_num_;


+ 5
- 0
mindspore/ccsrc/plugin/device/cpu/kernel/ps/sparse_apply_lazy_adam_ps_kernel.h View File

@@ -43,6 +43,11 @@ class SparseApplyLazyAdamPSKernelMod : public SparseApplyLazyAdamCpuKernelMod, p

protected:
void ReInit(const std::vector<AddressPtr> &) override;
size_t var_index_{0};
size_t m_index_{1};
size_t v_index_{2};
size_t grad_index_{9};
size_t indices_index_{10};
};
} // namespace ps
} // namespace kernel


+ 2
- 2
mindspore/ccsrc/plugin/device/gpu/hal/device/distribution/collective_fake_init.cc View File

@@ -30,12 +30,12 @@ void CollectiveFakeInitializer::FinalizeCollective() {
"this MindSpore package is GPU version and built with NCCL.";
}

uint32_t CollectiveFakeInitializer::GetRankID(const std::string &group_name) {
uint32_t CollectiveFakeInitializer::GetRankID(const std::string &) {
MS_LOG(EXCEPTION) << "You are trying to call 'GetRankID', Please check "
"this MindSpore package is GPU version and built with NCCL.";
}

uint32_t CollectiveFakeInitializer::GetRankSize(const std::string &group_name) {
uint32_t CollectiveFakeInitializer::GetRankSize(const std::string &) {
MS_LOG(EXCEPTION) << "You are trying to call 'GetRankSize', Please check "
"this MindSpore package is GPU version and built with NCCL.";
}


+ 1
- 1
mindspore/ccsrc/plugin/device/gpu/hal/hardware/nvidia_collective_comm_lib.h View File

@@ -57,7 +57,7 @@ class EXPORT_NCCL_WRAPPER NvidiaCollectiveCommLib : public CollectiveCommunicati
return instance;
}

bool Initialize(uint32_t global_rank = UINT32_MAX, uint32_t global_rank_size = UINT32_MAX) override;
bool Initialize(uint32_t global_rank, uint32_t global_rank_size) override;

bool CreateCommunicationGroup(const std::string &group_name, const std::vector<uint32_t> &group_ranks) override;



+ 0
- 1
mindspore/ccsrc/plugin/device/gpu/kernel/nccl/nccl_collective_gpu_kernel.cc View File

@@ -57,6 +57,5 @@ MS_REG_GPU_KERNEL_ONE(
MS_REG_GPU_KERNEL_ONE(Broadcast,
KernelAttr().AddAllSameAttr(true).AddInputAttr(kNumberTypeInt32).AddOutputAttr(kNumberTypeInt32),
NcclCollectiveGpuKernel, int)

} // namespace kernel
} // namespace mindspore

+ 0
- 5
mindspore/ccsrc/ps/constants.h View File

@@ -115,11 +115,6 @@ constexpr uint32_t kCheckRegisteredRetryCount = 30;
// The timeout interval for judging whether all nodes are successfully registered.
constexpr uint32_t kCheckRegisteredIntervalInMs = 1000;

// The barrier function which should be called before doing scaling out/in operations.
// It's easy for us to scale out/in nodes after one iteration is completed and keep consistent.
using BarrierBeforeScaleOut = std::function<void(void)>;
using BarrierBeforeScaleIn = std::function<void(void)>;

constexpr int64_t kSparseLazyAdamIndex = 2;
constexpr int64_t kSparseFtrlIndex = 3;
constexpr int64_t kSparseGradIndex = 6;


+ 4
- 2
mindspore/ccsrc/ps/ps_cache/embedding_hash_map.h View File

@@ -61,8 +61,10 @@ class EmbeddingHashMap {
virtual ~EmbeddingHashMap() = default;
int ParseData(const int id, int *const swap_out_index, int *const swap_out_ids, const size_t data_step,
const size_t graph_running_step, size_t *const swap_out_size, bool *const need_wait_graph);
size_t hash_step(const int hash_index) const { return hash_map_elements_[hash_index].step_; }
void set_hash_step(const int hash_index, const size_t step) { hash_map_elements_[hash_index].set_step(step); }
size_t hash_step(const int hash_index) const { return hash_map_elements_[IntToSize(hash_index)].step_; }
void set_hash_step(const int hash_index, const size_t step) {
hash_map_elements_[IntToSize(hash_index)].set_step(step);
}
const mindspore::HashMap<int, int> &hash_id_to_index() const { return hash_id_to_index_; }
size_t hash_capacity() const { return hash_capacity_; }
void DumpHashMap();


+ 1
- 1
mindspore/ccsrc/ps/ps_cache/ps_cache_basic.h View File

@@ -27,7 +27,7 @@ class PsCacheBasic {
virtual ~PsCacheBasic() = default;
virtual bool InitDevice(uint32_t device_id, const void *context) = 0;
virtual void *MallocMemory(size_t size) = 0;
virtual bool MallocConstantMemory(size_t cache_vocab_size) { return true; }
virtual bool MallocConstantMemory(size_t) { return true; }
virtual void FreeMemory(void *buf) = 0;
virtual bool RecordEvent() = 0;
virtual bool SynchronizeEvent() = 0;


+ 8
- 8
mindspore/ccsrc/runtime/collective/communication_group.h View File

@@ -85,14 +85,14 @@ using CommunicationGroupPtr = std::shared_ptr<CommunicationGroup>;
} // namespace device
} // namespace mindspore

#define CHECK_RET(expression, result, message) \
do { \
auto ret = (expression); \
if (ret != result) { \
std::ostringstream oss; \
oss << "Error in file " << __FILE__ << " | Error on line " << __LINE__ << ": " << message; \
pybind11::pybind11_fail(oss.str()); \
} \
#define CHECK_RET(expression, result, message) \
do { \
auto ret = (expression); \
if (ret != result) { \
std::ostringstream oss; \
oss << "Error in file " << __FILE__ << " | Error on line " << __LINE__ << ": " << (message); \
pybind11::pybind11_fail(oss.str()); \
} \
} while (0)

#define CHECK_IF_NULL(ptr) \


Loading…
Cancel
Save