!23660 textcnn bug fix and codedex fix

Merge pull request !23660 from huangbo/master_codedex
This commit is contained in:
i-robot 2021-09-18 01:10:02 +00:00 committed by Gitee
commit fc37f44f90
5 changed files with 11 additions and 10 deletions

View File

@ -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<T>::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<size_t>(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

View File

@ -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<kernel::AddressPtr> &inputs,

View File

@ -23,8 +23,8 @@ template <typename T, typename U>
void AtomicAddTask(T *const address, const T val) {
auto *address_as_ull = reinterpret_cast<U *>(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<T *>(&assumed);

View File

@ -6097,6 +6097,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,

View File

@ -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)