From cd15d171f14049e935298f893a65a042918046e2 Mon Sep 17 00:00:00 2001 From: Da Zheng Date: Wed, 15 Aug 2018 11:13:57 -0700 Subject: [PATCH 1/4] fix a bug. --- src/imperative/cached_op.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/imperative/cached_op.cc b/src/imperative/cached_op.cc index 1e7f8e0de1b3..85b557474941 100644 --- a/src/imperative/cached_op.cc +++ b/src/imperative/cached_op.cc @@ -823,9 +823,10 @@ OpStatePtr CachedOp::DynamicForward( // If we are already recording, we don't need RunGraph to record all // computation again. + if (recording && !inlining_) recording = false; RunGraph(false, idx, arrays, 0, idx.num_nodes(), std::move(array_reqs), std::move(ref_count), &states, dispatch_modes, - !recording || inlining_); + recording); return op_state; } From 85a2497c11ce137f7c93e7f6edd28f91f8db5f06 Mon Sep 17 00:00:00 2001 From: Da Zheng Date: Wed, 15 Aug 2018 14:57:19 -0700 Subject: [PATCH 2/4] address comments. --- src/imperative/cached_op.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/imperative/cached_op.cc b/src/imperative/cached_op.cc index 85b557474941..81116afd5add 100644 --- a/src/imperative/cached_op.cc +++ b/src/imperative/cached_op.cc @@ -821,8 +821,9 @@ OpStatePtr CachedOp::DynamicForward( const auto& dispatch_modes = g.GetAttr("dispatch_mode"); - // If we are already recording, we don't need RunGraph to record all - // computation again. + // If CachedOp is running in the inline mode, it uses RunGraph to record + // computation; otherwise, CachedOp records computation itself. + // So if it's not the inline mode, we disable recording. if (recording && !inlining_) recording = false; RunGraph(false, idx, arrays, 0, idx.num_nodes(), std::move(array_reqs), std::move(ref_count), &states, dispatch_modes, From 79ccecdfa12a835478f21a5c77093f6a83c41333 Mon Sep 17 00:00:00 2001 From: Da Zheng Date: Thu, 16 Aug 2018 10:25:37 -0700 Subject: [PATCH 3/4] retrigger From 65a53aafd9312987bbfdba625a2d8212211fc64a Mon Sep 17 00:00:00 2001 From: Da Zheng Date: Thu, 16 Aug 2018 20:44:32 -0700 Subject: [PATCH 4/4] address comments. --- src/imperative/cached_op.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/imperative/cached_op.cc b/src/imperative/cached_op.cc index 81116afd5add..0c4c1e60208f 100644 --- a/src/imperative/cached_op.cc +++ b/src/imperative/cached_op.cc @@ -824,10 +824,9 @@ OpStatePtr CachedOp::DynamicForward( // If CachedOp is running in the inline mode, it uses RunGraph to record // computation; otherwise, CachedOp records computation itself. // So if it's not the inline mode, we disable recording. - if (recording && !inlining_) recording = false; RunGraph(false, idx, arrays, 0, idx.num_nodes(), std::move(array_reqs), std::move(ref_count), &states, dispatch_modes, - recording); + recording && inlining_); return op_state; }