Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Update cached_op.cc #11310

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/imperative/cached_op.cc
Expand Up @@ -674,7 +674,7 @@ OpStatePtr CachedOp::StaticForward(
std::lock_guard<std::mutex> lock(state.mutex);

bool match = SetForwardGraph(&state.info, recording, inputs);
match = match && state.recording != recording;
match = match && state.recording == recording;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test?


nnvm::Graph& g = state.info.fwd_graph;
const auto& idx = g.indexed_graph();
Expand Down
11 changes: 11 additions & 0 deletions tests/python/unittest/test_gluon.py
Expand Up @@ -1285,6 +1285,17 @@ def test_legacy_save_params():
model.load_params('test.params', ctx=mx.cpu())


def test_hybrid_static_memory_recording():
net = gluon.model_zoo.vision.get_resnet(
1, 18, pretrained=True, ctx=mx.context.current_context())
net.hybridize(static_alloc=True)

x = mx.nd.random.uniform(shape=(1, 3, 32, 32))
with mx.autograd.record(True):
net(x)
net(x)


if __name__ == '__main__':
import nose
nose.runmodule()