From 2065ec8fe1fd555d816c9a667936351515208913 Mon Sep 17 00:00:00 2001 From: huangbo77 Date: Fri, 17 Sep 2021 11:02:34 +0800 Subject: [PATCH] master codedex fix --- .../kernel_compiler/cpu/nms_with_mask_cpu_kernel.cc | 6 +++--- .../cpu/random_choice_with_mask_cpu_kernel.cc | 8 ++++---- .../kernel_compiler/cpu/roi_align_grad_cpu_kernel.cc | 4 ++-- mindspore/ops/operations/array_ops.py | 1 + model_zoo/official/nlp/textcnn/src/dataset.py | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/nms_with_mask_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/nms_with_mask_cpu_kernel.cc index 73c5e18adef..f91f7447c1c 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/nms_with_mask_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/nms_with_mask_cpu_kernel.cc @@ -19,10 +19,10 @@ namespace mindspore { namespace kernel { -size_t NmsRoundUpPower2(int v) { +uint32_t NmsRoundUpPower2(int v) { constexpr uint32_t ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8, SIXTEEN = 16; v--; - size_t value = IntToSize(v); + uint32_t value = IntToUint(v); value |= value >> ONE; value |= value >> TWO; value |= value >> FOUR; @@ -216,7 +216,7 @@ void NMSWithMaskCPUKernel::InitInputOutputSize(const CNodePtr &kernel_node) { CPUKernel::InitInputOutputSize(kernel_node); auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0); num_input_ = SizeToInt(input_shape[0]); // Get N values in [N, 5] data. - ceil_power_2 = NmsRoundUpPower2(num_input_); + ceil_power_2 = static_cast(NmsRoundUpPower2(num_input_)); workspace_size_list_.push_back(ceil_power_2 * sizeof(T)); // data buff workspace_size_list_.push_back(ceil_power_2 * sizeof(int)); // index buff diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/random_choice_with_mask_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/random_choice_with_mask_cpu_kernel.cc index a838e012c3d..38d30e203a8 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/random_choice_with_mask_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/random_choice_with_mask_cpu_kernel.cc @@ -118,12 +118,12 @@ void RandomChoiceWithMaskCPUKernel::InitInputOutputSize(const CNodePtr &kernel_n CPUKernel::InitInputOutputSize(kernel_node); GetInputTotalCount(dims_, &input_total_count, input_dim_size); - size_t temp_output_length = count_ > 0 ? count_ : input_total_count; + int temp_output_length = count_ > 0 ? count_ : input_total_count; workspace_size_list_.push_back(IntToSize(input_total_count) * sizeof(int)); - workspace_size_list_.push_back(temp_output_length * sizeof(int)); - workspace_size_list_.push_back(temp_output_length * sizeof(int)); - workspace_size_list_.push_back(temp_output_length * IntToSize(input_dim_size) * sizeof(int)); + workspace_size_list_.push_back(IntToSize(temp_output_length) * sizeof(int)); + workspace_size_list_.push_back(IntToSize(temp_output_length) * sizeof(int)); + workspace_size_list_.push_back(IntToSize(temp_output_length) * IntToSize(input_dim_size) * sizeof(int)); } bool RandomChoiceWithMaskCPUKernel::Launch(const std::vector &inputs, diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/roi_align_grad_cpu_kernel.cc b/mindspore/ccsrc/backend/kernel_compiler/cpu/roi_align_grad_cpu_kernel.cc index f202469333d..8d3384101a7 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/roi_align_grad_cpu_kernel.cc +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/roi_align_grad_cpu_kernel.cc @@ -23,8 +23,8 @@ template void AtomicAddTask(T *const address, const T val) { auto *address_as_ull = reinterpret_cast(address); U old = *address_as_ull; - U assumed; - T desired; + U assumed = U(0); + T desired = T(0); do { assumed = old; T *assumed_t = reinterpret_cast(&assumed); diff --git a/mindspore/ops/operations/array_ops.py b/mindspore/ops/operations/array_ops.py index 423985ca202..f6379fac586 100755 --- a/mindspore/ops/operations/array_ops.py +++ b/mindspore/ops/operations/array_ops.py @@ -6000,6 +6000,7 @@ class SearchSorted(PrimitiveWithInfer): validator.check_tensors_dtypes_same_and_valid(args, mstype.number_type, self.name) return mstype.tensor_type(mstype.int32) if self.out_int32 else mstype.tensor_type(mstype.int64) + class TensorScatterMax(PrimitiveWithInfer): """ By comparing the value at the position indicated by the index in input_x with the value in the update, diff --git a/model_zoo/official/nlp/textcnn/src/dataset.py b/model_zoo/official/nlp/textcnn/src/dataset.py index 192e7ffa9e9..1398b6c6d6a 100644 --- a/model_zoo/official/nlp/textcnn/src/dataset.py +++ b/model_zoo/official/nlp/textcnn/src/dataset.py @@ -129,7 +129,7 @@ class MovieReview(DataProcessor): self.Pos = [] self.Neg = [] for filename in self.files: - with codecs.open(filename, 'r') as f: + with codecs.open(filename, 'r', 'Latin1') as f: ff = f.read() with codecs.open(filename, 'w', 'utf-8') as file_object: file_object.write(ff)