Skip to content

Commit

Permalink
Merge branch 'itikhono/memory/update_evaluates' into new_state_behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnick committed Dec 1, 2023
2 parents 1eab16a + 82c28e8 commit 573b03e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/core/src/op/assign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ bool Assign::evaluate(TensorVector& outputs,

const auto var_value = variable_values.find(m_variable)->second;
var_value->set_reset(false);
auto buffer = var_value->get_state();
buffer.set_shape(inputs[0].get_shape());
auto memory_buffer = var_value->get_state();
memory_buffer.set_shape(inputs[0].get_shape());
outputs[0].set_shape(inputs[0].get_shape());

std::memcpy(outputs[0].data(), inputs[0].data(), inputs[0].get_byte_size());
std::memcpy(buffer.data(), inputs[0].data(), inputs[0].get_byte_size());
std::memcpy(memory_buffer.data(), inputs[0].data(), inputs[0].get_byte_size());

return true;
}
Expand Down
9 changes: 5 additions & 4 deletions src/core/src/op/read_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ bool ReadValue::evaluate(TensorVector& outputs,
const auto use_context = var_value != variable_values.end() && !var_value->second->get_reset();

auto& output = outputs[0];
const auto& input = inputs[0];
if (use_context) {
const auto& ctx_tensor = var_value->second->get_state();
output.set_shape(ctx_tensor.get_shape());
std::memcpy(output.data(), ctx_tensor.data(), output.get_byte_size());
const auto& memory_buffer = var_value->second->get_state();
output.set_shape(memory_buffer.get_shape());
std::memcpy(output.data(), memory_buffer.data(), output.get_byte_size());
} else {
output.set_shape(inputs[0].get_shape());
std::memset(output.data(), 0, output.get_byte_size());
std::memcpy(output.data(), input.data(), output.get_byte_size());
}
return true;
}
Expand Down

0 comments on commit 573b03e

Please sign in to comment.