Browse Source

!15117 fix codedex

From: @limingqi107
Reviewed-by: @cristoval,@wilfchen
Signed-off-by: @wilfchen
pull/15117/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
3cffa4752e
13 changed files with 24 additions and 24 deletions
  1. +1
    -1
      mindspore/ccsrc/backend/kernel_compiler/kernel.h
  2. +0
    -1
      mindspore/ccsrc/backend/optimizer/gpu/cudnn_inplace_fusion.cc
  3. +5
    -4
      mindspore/ccsrc/ps/ps_cache/embedding_hash_map.cc
  4. +4
    -3
      mindspore/ccsrc/ps/ps_cache/embedding_hash_map.h
  5. +2
    -3
      mindspore/ccsrc/ps/ps_cache/ps_cache_manager.cc
  6. +2
    -1
      mindspore/ccsrc/ps/ps_cache/ps_cache_manager.h
  7. +2
    -2
      mindspore/ccsrc/ps/ps_cache/ps_data/ps_data_channel.cc
  8. +2
    -2
      mindspore/ccsrc/ps/ps_cache/ps_data/ps_data_channel.h
  9. +1
    -1
      mindspore/ccsrc/ps/ps_cache/ps_data/ps_data_prefetch.cc
  10. +0
    -1
      mindspore/ccsrc/runtime/device/gpu/gpu_device_manager.cc
  11. +0
    -1
      mindspore/ccsrc/runtime/device/gpu/gpu_kernel_runtime.cc
  12. +3
    -2
      mindspore/ccsrc/runtime/device/kernel_runtime.cc
  13. +2
    -2
      mindspore/ccsrc/runtime/device/kernel_runtime.h

+ 1
- 1
mindspore/ccsrc/backend/kernel_compiler/kernel.h View File

@@ -116,7 +116,7 @@ using KernelPackPtr = std::shared_ptr<KernelPack>;
* @brief base class for autotensor kernel and cce kernel.
*/
struct Address {
Address() {}
Address() : addr(nullptr), size(0) {}
Address(void *address_addr, size_t address_size) : addr(address_addr), size(address_size) {}
void *addr;
size_t size;


+ 0
- 1
mindspore/ccsrc/backend/optimizer/gpu/cudnn_inplace_fusion.cc View File

@@ -105,7 +105,6 @@ void CheckInplaceNodeInputs(std::vector<AnfNodeIndex> *inplace_node, const FuncG
auto second_cnode = (*inplace_node)[1].node->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(second_cnode);
auto second_node_input = second_cnode->input(1);

// if two inplace nodes have same input, will be have loop after insert depend
// so copy a new input for one of inplace node
if (first_node_input == second_node_input) {


+ 5
- 4
mindspore/ccsrc/ps/ps_cache/embedding_hash_map.cc View File

@@ -18,8 +18,9 @@

namespace mindspore {
namespace ps {
int EmbeddingHashMap::ParseData(const int id, int *swap_out_index, int *swap_out_ids, const size_t data_step,
const size_t graph_running_step, size_t *swap_out_size, bool *need_wait_graph) {
int EmbeddingHashMap::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) {
MS_EXCEPTION_IF_NULL(swap_out_index);
MS_EXCEPTION_IF_NULL(swap_out_ids);
MS_EXCEPTION_IF_NULL(swap_out_size);
@@ -47,8 +48,8 @@ int EmbeddingHashMap::ParseData(const int id, int *swap_out_index, int *swap_out
return hash_index;
}

int EmbeddingHashMap::FindInsertionPos(const size_t data_step, const size_t graph_running_step, bool *need_swap,
bool *need_wait_graph) {
int EmbeddingHashMap::FindInsertionPos(const size_t data_step, const size_t graph_running_step, bool *const need_swap,
bool *const need_wait_graph) {
MS_EXCEPTION_IF_NULL(need_swap);
MS_EXCEPTION_IF_NULL(need_wait_graph);
int hash_index = INVALID_INDEX_VALUE;


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

@@ -59,8 +59,8 @@ class EmbeddingHashMap {
graph_running_index_ = std::make_unique<int[]>(hash_capacity);
}
virtual ~EmbeddingHashMap() = default;
int ParseData(const int id, int *swap_out_index, int *swap_out_ids, const size_t data_step,
const size_t graph_running_step, size_t *swap_out_size, bool *need_wait_graph);
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); }
const std::unordered_map<int, int> &hash_id_to_index() const { return hash_id_to_index_; }
@@ -69,7 +69,8 @@ class EmbeddingHashMap {
void Reset();

private:
int FindInsertionPos(const size_t data_step, const size_t graph_running_step, bool *need_swap, bool *need_wait_graph);
int FindInsertionPos(const size_t data_step, const size_t graph_running_step, bool *const need_swap,
bool *const need_wait_graph);
size_t hash_count_;
size_t hash_capacity_;
std::vector<HashMapElement> hash_map_elements_;


+ 2
- 3
mindspore/ccsrc/ps/ps_cache/ps_cache_manager.cc View File

@@ -1086,8 +1086,8 @@ void PsCacheManager::DumpHashTables(bool dump_device_tables) const {
<< ", device cache address:" << reinterpret_cast<void *>(item.second.device_address.addr)
<< ", host cache address:" << reinterpret_cast<void *>(item.second.host_address.get());
if (dump_device_tables) {
float *output = new float[item.second.device_address.size / 4];
embedding_device_cache_->cache_->CopyDeviceMemToHost(output, item.second.device_address.addr,
std::unique_ptr<float[]> output = std::make_unique<float[]>(item.second.device_address.size / 4);
embedding_device_cache_->cache_->CopyDeviceMemToHost(output.get(), item.second.device_address.addr,
item.second.device_address.size);
embedding_device_cache_->cache_->SynchronizeStream();
for (size_t i = 0; i < cache_vocab_size; i++) {
@@ -1097,7 +1097,6 @@ void PsCacheManager::DumpHashTables(bool dump_device_tables) const {
std::cout << std::endl;
}
std::cout << std::endl;
delete[] output;
}
}
}


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

@@ -54,7 +54,8 @@ struct HashTableInfo {
};

struct EmbeddingDeviceCache {
EmbeddingDeviceCache(size_t batch_elements, size_t cache_vocab_size) {
EmbeddingDeviceCache(size_t batch_elements, size_t cache_vocab_size)
: hash_swap_index_addr_(nullptr), hash_swap_value_addr_(nullptr) {
device_to_host_index = std::make_unique<int[]>(batch_elements);
device_to_host_ids = std::make_unique<int[]>(batch_elements);
host_to_device_index = std::make_unique<int[]>(batch_elements);


+ 2
- 2
mindspore/ccsrc/ps/ps_cache/ps_data/ps_data_channel.cc View File

@@ -42,10 +42,10 @@ void PsDataChannel::TryWakeChannel(bool force_wake) {
current_graph_step_++;
}

void PsDataChannel::set_data(void *data, const size_t data_size) {
void PsDataChannel::set_data(const void *data, const size_t data_size) {
MS_EXCEPTION_IF_NULL(data);
TryLockChannel();
data_ = data;
data_ = const_cast<void *>(data);
data_size_ = data_size;
}
} // namespace ps


+ 2
- 2
mindspore/ccsrc/ps/ps_cache/ps_data/ps_data_channel.h View File

@@ -33,8 +33,8 @@ class PsDataChannel {
data_(nullptr),
data_size_(0) {}
virtual ~PsDataChannel() = default;
void set_data(void *data, const size_t data_size);
void *data() const { return data_; }
void set_data(const void *data, const size_t data_size);
const void *data() const { return data_; }
size_t data_size() const { return data_size_; }
void ResetData() { data_ = nullptr; }
void set_step_num(size_t step_num) { step_num_ = step_num; }


+ 1
- 1
mindspore/ccsrc/ps/ps_cache/ps_data/ps_data_prefetch.cc View File

@@ -118,7 +118,7 @@ bool PsDataPrefetch::QueryData(const std::string &channel_name, void **data_ptr)
*data_ptr = nullptr;
return true;
}
*data_ptr = channel->data();
*data_ptr = const_cast<void *>(channel->data());
return true;
}



+ 0
- 1
mindspore/ccsrc/runtime/device/gpu/gpu_device_manager.cc View File

@@ -117,7 +117,6 @@ bool GPUDeviceManager::CopyDeviceMemToDeviceAsync(const DeviceMemPtr &dst, const
DeviceStream stream) const {
return CudaDriver::CopyDeviceMemToDeviceAsync(dst, src, size, stream);
}
} // namespace gpu
} // namespace device
} // namespace mindspore

+ 0
- 1
mindspore/ccsrc/runtime/device/gpu/gpu_kernel_runtime.cc View File

@@ -102,7 +102,6 @@ bool GPUKernelRuntime::Init() {
}

namespace {

std::vector<int> CheckRealOutput(const std::string &node_name, const size_t &output_size) {
// define a vector containing real output number
std::vector<int> real_outputs;


+ 3
- 2
mindspore/ccsrc/runtime/device/kernel_runtime.cc View File

@@ -1038,8 +1038,9 @@ DeviceAddressPtr KernelRuntime::AssignSingleOpLaunchMemory(size_t size, const st
}

#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU))
void KernelRuntime::GetFirstPSEmbeddingCache(const session::KernelGraph *graph, AnfNodePtr *first_cache_input_index,
size_t *first_cache_size) {
void KernelRuntime::GetFirstPSEmbeddingCache(const session::KernelGraph *graph,
AnfNodePtr *const first_cache_input_index,
size_t *const first_cache_size) {
MS_EXCEPTION_IF_NULL(graph);
for (const auto &kernel : graph->execution_order()) {
MS_EXCEPTION_IF_NULL(kernel);


+ 2
- 2
mindspore/ccsrc/runtime/device/kernel_runtime.h View File

@@ -143,8 +143,8 @@ class KernelRuntime {
void AssignValueNodeTensor(const ValueNodePtr &value_node, const ValuePtr &node_value, size_t output_idx);
DeviceAddressPtr PreAssignCNodeMemory(const AnfNodePtr &anf_node, size_t index);
#if (ENABLE_CPU && (ENABLE_D || ENABLE_GPU))
void GetFirstPSEmbeddingCache(const session::KernelGraph *graph, AnfNodePtr *first_cache_input_index,
size_t *first_cache_size);
void GetFirstPSEmbeddingCache(const session::KernelGraph *graph, AnfNodePtr *const first_cache_input_index,
size_t *const first_cache_size);
void CheckIfSupportPSEmbeddingCache(const session::KernelGraph *graph);
void CheckSparsePSEmbeddingCache(const CNodePtr &node);
#endif


Loading…
Cancel
Save