replace unsafe function

This commit is contained in:
kingfo 2020-07-15 18:13:03 +08:00
parent 8300802b95
commit cdadcb4a70
1 changed files with 4 additions and 3 deletions

View File

@ -153,7 +153,7 @@ AnfNodePtr TensorMultiplyBase::NewTensorFilledWithData(const AnfNodePtr &node, c
char *data = reinterpret_cast<char *>(new_tensor_ptr->data_c()); char *data = reinterpret_cast<char *>(new_tensor_ptr->data_c());
if (x == nullptr) { if (x == nullptr) {
std::memset(data, 0, mem_size); memset_s(data, mem_size, 0, mem_size);
auto new_vnode = NewValueNode(new_tensor_ptr); auto new_vnode = NewValueNode(new_tensor_ptr);
new_vnode->set_abstract(new_tensor_ptr->ToAbstract()); new_vnode->set_abstract(new_tensor_ptr->ToAbstract());
return new_vnode; return new_vnode;
@ -188,10 +188,11 @@ AnfNodePtr TensorMultiplyBase::NewTensorFilledWithData(const AnfNodePtr &node, c
char *source_data = reinterpret_cast<char *>(GetPointerToTensorData(x)); char *source_data = reinterpret_cast<char *>(GetPointerToTensorData(x));
if (x_tensor_ptr->DataSize() == 1) { if (x_tensor_ptr->DataSize() == 1) {
for (int i = 0; i < new_tensor_ptr->ElementsNum(); i++) { for (int i = 0; i < new_tensor_ptr->ElementsNum(); i++) {
memcpy(data + i * GetTypeByte(tensor_type_ptr), source_data, GetTypeByte(tensor_type_ptr)); memcpy_s(data + i * GetTypeByte(tensor_type_ptr), GetTypeByte(tensor_type_ptr), source_data,
GetTypeByte(tensor_type_ptr));
} }
} else { } else {
memcpy(data, source_data, mem_size); memcpy_s(data, mem_size, source_data, mem_size);
} }
auto new_vnode = NewValueNode(new_tensor_ptr); auto new_vnode = NewValueNode(new_tensor_ptr);
new_vnode->set_abstract(new_tensor_ptr->ToAbstract()); new_vnode->set_abstract(new_tensor_ptr->ToAbstract());