forked from mindspore-Ecosystem/mindspore
!23660 textcnn bug fix and codedex fix
Merge pull request !23660 from huangbo/master_codedex
This commit is contained in:
commit
fc37f44f90
|
@ -19,10 +19,10 @@
|
||||||
|
|
||||||
namespace mindspore {
|
namespace mindspore {
|
||||||
namespace kernel {
|
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;
|
constexpr uint32_t ONE = 1, TWO = 2, FOUR = 4, EIGHT = 8, SIXTEEN = 16;
|
||||||
v--;
|
v--;
|
||||||
size_t value = IntToSize(v);
|
uint32_t value = IntToUint(v);
|
||||||
value |= value >> ONE;
|
value |= value >> ONE;
|
||||||
value |= value >> TWO;
|
value |= value >> TWO;
|
||||||
value |= value >> FOUR;
|
value |= value >> FOUR;
|
||||||
|
@ -216,7 +216,7 @@ void NMSWithMaskCPUKernel<T>::InitInputOutputSize(const CNodePtr &kernel_node) {
|
||||||
CPUKernel::InitInputOutputSize(kernel_node);
|
CPUKernel::InitInputOutputSize(kernel_node);
|
||||||
auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||||
num_input_ = SizeToInt(input_shape[0]); // Get N values in [N, 5] data.
|
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(T)); // data buff
|
||||||
workspace_size_list_.push_back(ceil_power_2 * sizeof(int)); // index buff
|
workspace_size_list_.push_back(ceil_power_2 * sizeof(int)); // index buff
|
||||||
|
|
|
@ -118,12 +118,12 @@ void RandomChoiceWithMaskCPUKernel::InitInputOutputSize(const CNodePtr &kernel_n
|
||||||
CPUKernel::InitInputOutputSize(kernel_node);
|
CPUKernel::InitInputOutputSize(kernel_node);
|
||||||
|
|
||||||
GetInputTotalCount(dims_, &input_total_count, input_dim_size);
|
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(IntToSize(input_total_count) * sizeof(int));
|
||||||
workspace_size_list_.push_back(temp_output_length * sizeof(int));
|
workspace_size_list_.push_back(IntToSize(temp_output_length) * sizeof(int));
|
||||||
workspace_size_list_.push_back(temp_output_length * sizeof(int));
|
workspace_size_list_.push_back(IntToSize(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) * IntToSize(input_dim_size) * sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RandomChoiceWithMaskCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
bool RandomChoiceWithMaskCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
|
||||||
|
|
|
@ -23,8 +23,8 @@ template <typename T, typename U>
|
||||||
void AtomicAddTask(T *const address, const T val) {
|
void AtomicAddTask(T *const address, const T val) {
|
||||||
auto *address_as_ull = reinterpret_cast<U *>(address);
|
auto *address_as_ull = reinterpret_cast<U *>(address);
|
||||||
U old = *address_as_ull;
|
U old = *address_as_ull;
|
||||||
U assumed;
|
U assumed = U(0);
|
||||||
T desired;
|
T desired = T(0);
|
||||||
do {
|
do {
|
||||||
assumed = old;
|
assumed = old;
|
||||||
T *assumed_t = reinterpret_cast<T *>(&assumed);
|
T *assumed_t = reinterpret_cast<T *>(&assumed);
|
||||||
|
|
|
@ -6097,6 +6097,7 @@ class SearchSorted(PrimitiveWithInfer):
|
||||||
validator.check_tensors_dtypes_same_and_valid(args, mstype.number_type, self.name)
|
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)
|
return mstype.tensor_type(mstype.int32) if self.out_int32 else mstype.tensor_type(mstype.int64)
|
||||||
|
|
||||||
|
|
||||||
class TensorScatterMax(PrimitiveWithInfer):
|
class TensorScatterMax(PrimitiveWithInfer):
|
||||||
"""
|
"""
|
||||||
By comparing the value at the position indicated by the index in input_x with the value in the update,
|
By comparing the value at the position indicated by the index in input_x with the value in the update,
|
||||||
|
|
|
@ -129,7 +129,7 @@ class MovieReview(DataProcessor):
|
||||||
self.Pos = []
|
self.Pos = []
|
||||||
self.Neg = []
|
self.Neg = []
|
||||||
for filename in self.files:
|
for filename in self.files:
|
||||||
with codecs.open(filename, 'r') as f:
|
with codecs.open(filename, 'r', 'Latin1') as f:
|
||||||
ff = f.read()
|
ff = f.read()
|
||||||
with codecs.open(filename, 'w', 'utf-8') as file_object:
|
with codecs.open(filename, 'w', 'utf-8') as file_object:
|
||||||
file_object.write(ff)
|
file_object.write(ff)
|
||||||
|
|
Loading…
Reference in New Issue