!18174 Fix codex issues in master
Merge pull request !18174 from h.farahat/new_codex_master
This commit is contained in:
commit
8805a386be
|
@ -59,12 +59,12 @@ Status NgramOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Te
|
|||
int32_t start_ind = l_len_ - std::min(l_len_, n - 1);
|
||||
int32_t end_ind = offsets.size() - r_len_ + std::min(r_len_, n - 1);
|
||||
if (end_ind - start_ind <= n) {
|
||||
res.emplace_back(std::string()); // push back empty string
|
||||
(void)res.emplace_back(std::string()); // push back empty string
|
||||
} else {
|
||||
CHECK_FAIL_RETURN_UNEXPECTED(end_ind - n >= 0, "Ngram: get offsets failed.");
|
||||
|
||||
for (int ind = start_ind; ind < end_ind - n; ind++) {
|
||||
res.emplace_back(str_buffer.substr(offsets[ind], offsets[ind + n] - offsets[ind] - separator_.size()));
|
||||
(void)res.emplace_back(str_buffer.substr(offsets[ind], offsets[ind + n] - offsets[ind] - separator_.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ Status NgramOp::OutputShape(const std::vector<TensorShape> &inputs, std::vector<
|
|||
// if len_with_padding - n < 0, this would return an empty string
|
||||
num_elements += std::max(len_with_padding - n, 0);
|
||||
}
|
||||
outputs.emplace_back(TensorShape({num_elements}));
|
||||
(void)outputs.emplace_back(TensorShape({num_elements}));
|
||||
CHECK_FAIL_RETURN_UNEXPECTED(outputs.size() == NumOutput(), "Ngram: incorrect num of outputs\n");
|
||||
return Status::OK();
|
||||
}
|
||||
|
|
|
@ -1752,6 +1752,7 @@ class Dataset:
|
|||
"""Reset the dataset for next epoch."""
|
||||
|
||||
def is_shuffled(self):
|
||||
"""Returns True if the dataset or its children is shuffled."""
|
||||
for input_dataset in self.children:
|
||||
if input_dataset.is_shuffled():
|
||||
return True
|
||||
|
@ -1759,6 +1760,7 @@ class Dataset:
|
|||
return False
|
||||
|
||||
def is_sharded(self):
|
||||
"""Returns True if the dataset or its children is sharded."""
|
||||
for input_dataset in self.children:
|
||||
if input_dataset.is_sharded():
|
||||
return True
|
||||
|
|
|
@ -149,7 +149,7 @@ class String {
|
|||
if (buffer_ == nullptr) {
|
||||
MS_C_EXCEPTION("malloc data failed");
|
||||
}
|
||||
strncpy(buffer_, other.buffer_ + pos, size_);
|
||||
strncpy_s(buffer_, size_ + 1, other.buffer_ + pos, size_);
|
||||
buffer_[size_] = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ class String {
|
|||
MS_C_EXCEPTION("malloc data failed");
|
||||
}
|
||||
memcpy(tmp, this->buffer_, size_ + 1);
|
||||
strncat(tmp, str.buffer_, str.size_);
|
||||
strncat_s(tmp, new_size + 1, str.buffer_, str.size_);
|
||||
tmp[new_size] = '\0';
|
||||
free(buffer_);
|
||||
buffer_ = tmp;
|
||||
|
|
Loading…
Reference in New Issue