Skip to content

Commit 9aa1b3e

Browse files
d1jangfacebook-github-bot
authored andcommitted
[Static Runtime] [Code Cleanup] Encapsulate function objects within ProcessedFunction (pytorch#69595)
Summary: Pull Request resolved: pytorch#69595 This changes encapsulates `function` object in `ProcessedFunction` objects instead of exposing it unnecessarily just for executing it. Test Plan: Existing tests Reviewed By: mikeiovine Differential Revision: D32908341 fbshipit-source-id: 5ff4951cbe276c5c6292227124d9eec1dd16e364
1 parent 41e1ab0 commit 9aa1b3e

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

benchmarks/static_runtime/test_static_module.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,6 @@ TEST(ProcessedFunction, ProcessedFunction) {
976976
sigmoid_node,
977977
/*enable_out_variant=*/true,
978978
/*check_memory_overlap=*/false);
979-
EXPECT_TRUE(sigmoid_fn.f());
980979
EXPECT_EQ(sigmoid_fn.kind(), ProcessedFunction::Kind::kOutVariant);
981980
EXPECT_FALSE(sigmoid_fn.checkMemoryOverlap());
982981

@@ -985,7 +984,6 @@ TEST(ProcessedFunction, ProcessedFunction) {
985984
transpose_node,
986985
/*enable_out_variant=*/true,
987986
/*check_memory_overlap=*/false);
988-
EXPECT_TRUE(transpose_fn.f());
989987
EXPECT_EQ(transpose_fn.kind(), ProcessedFunction::Kind::kNativeFunction);
990988
EXPECT_FALSE(transpose_fn.checkMemoryOverlap());
991989
}

torch/csrc/jit/runtime/static/impl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,12 +1700,12 @@ void ProcessedNode::run() {
17001700
guard.before(get_op_name());
17011701
}
17021702
}
1703-
fn_->f()(this);
1703+
fn_->run(this);
17041704
} else {
1705-
fn_->f()(this);
1705+
fn_->run(this);
17061706
}
17071707
#else
1708-
fn_->f()(this);
1708+
fn_->run(this);
17091709
#endif
17101710
#ifndef NDEBUG
17111711
if (FLAGS_static_runtime_disable_debug_memory_overlap_check) {

torch/csrc/jit/runtime/static/impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ class TORCH_API ProcessedFunction {
570570
kInterpreterFallback,
571571
};
572572

573-
const std::function<void(ProcessedNode*)>& f() const {
574-
return f_;
573+
void run(ProcessedNode* pnode) const {
574+
return f_(pnode);
575575
}
576576

577577
Kind kind() const {

0 commit comments

Comments
 (0)