fix codex

This commit is contained in:
VectorSL 2022-03-21 10:08:34 +08:00
parent e59c7620e7
commit c1220ea054
4 changed files with 12 additions and 5 deletions

View File

@ -36,6 +36,10 @@ class BufferAppendCpuKernelMod : public NativeCpuKernelMod {
auto types = common::AnfAlgo::GetNodeAttr<std::vector<TypePtr>>(kernel_node, "buffer_dtype");
capacity_ = common::AnfAlgo::GetNodeAttr<int64_t>(kernel_node, "capacity");
exp_batch_ = common::AnfAlgo::GetNodeAttr<int64_t>(kernel_node, "exp_batch");
// check capacity > 0
if (capacity_ <= 0) {
MS_LOG(EXCEPTION) << "Capacity must be greater than 0 ";
}
element_nums_ = shapes.size();
for (size_t i = 0; i < element_nums_; i++) {
exp_element_list.push_back(LongToSize(shapes[i]) * UnitSizeInBytes(types[i]->type_id()));
@ -94,7 +98,7 @@ class BufferAppendCpuKernelMod : public NativeCpuKernelMod {
return true;
}
void InitKernel(const CNodePtr &kernel_node) { return; }
void InitKernel(const CNodePtr &) { return; }
private:
size_t element_nums_;

View File

@ -82,7 +82,7 @@ class BufferGetCpuKernelMod : public NativeCpuKernelMod {
return true;
}
void InitKernel(const CNodePtr &kernel_node) { return; }
void InitKernel(const CNodePtr &) { return; }
private:
size_t element_nums_;

View File

@ -24,6 +24,8 @@
namespace mindspore {
namespace kernel {
constexpr size_t kDouble = 2;
BufferAppendKernelMod::BufferAppendKernelMod() : element_nums_(0), exp_batch_(0), capacity_(0) {}
BufferAppendKernelMod::~BufferAppendKernelMod() {}
@ -60,8 +62,8 @@ void BufferAppendKernelMod::InitSizeLists() { return; }
bool BufferAppendKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std::vector<AddressPtr> &workspace,
const std::vector<AddressPtr> &, void *stream) {
int *count_addr = GetDeviceAddress<int>(inputs, 2 * element_nums_);
int *head_addr = GetDeviceAddress<int>(inputs, 2 * element_nums_ + 1);
int *count_addr = GetDeviceAddress<int>(inputs, kDouble * element_nums_);
int *head_addr = GetDeviceAddress<int>(inputs, kDouble * element_nums_ + 1);
int *index_addr = GetDeviceAddress<int>(workspace, 0);
auto cuda_stream = reinterpret_cast<cudaStream_t>(stream);
IncreaseCount(capacity_, LongToInt(exp_batch_), count_addr, head_addr, index_addr, cuda_stream);

View File

@ -24,6 +24,7 @@
namespace mindspore {
namespace kernel {
constexpr size_t kSecondInputIndex = 2;
BufferGetKernelMod::BufferGetKernelMod() : element_nums_(0), capacity_(0) {}
BufferGetKernelMod::~BufferGetKernelMod() {}
@ -58,7 +59,7 @@ bool BufferGetKernelMod::Launch(const std::vector<AddressPtr> &inputs, const std
const std::vector<AddressPtr> &outputs, void *stream) {
int *count_addr = GetDeviceAddress<int>(inputs, element_nums_);
int *head_addr = GetDeviceAddress<int>(inputs, element_nums_ + 1);
int *origin_index_addr = GetDeviceAddress<int>(inputs, element_nums_ + 2);
int *origin_index_addr = GetDeviceAddress<int>(inputs, element_nums_ + kSecondInputIndex);
int *index_addr = GetDeviceAddress<int>(workspace, 0);
auto cuda_stream = reinterpret_cast<cudaStream_t>(stream);
ReMappingIndex(count_addr, head_addr, origin_index_addr, index_addr, cuda_stream);