mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Static Runtime] [Code Cleanup] Encapsulate function objects within ProcessedFunction (#69595)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
41e1ab0785
commit
9aa1b3e396
@ -976,7 +976,6 @@ TEST(ProcessedFunction, ProcessedFunction) {
|
||||
sigmoid_node,
|
||||
/*enable_out_variant=*/true,
|
||||
/*check_memory_overlap=*/false);
|
||||
EXPECT_TRUE(sigmoid_fn.f());
|
||||
EXPECT_EQ(sigmoid_fn.kind(), ProcessedFunction::Kind::kOutVariant);
|
||||
EXPECT_FALSE(sigmoid_fn.checkMemoryOverlap());
|
||||
|
||||
@ -985,7 +984,6 @@ TEST(ProcessedFunction, ProcessedFunction) {
|
||||
transpose_node,
|
||||
/*enable_out_variant=*/true,
|
||||
/*check_memory_overlap=*/false);
|
||||
EXPECT_TRUE(transpose_fn.f());
|
||||
EXPECT_EQ(transpose_fn.kind(), ProcessedFunction::Kind::kNativeFunction);
|
||||
EXPECT_FALSE(transpose_fn.checkMemoryOverlap());
|
||||
}
|
||||
|
@ -1700,12 +1700,12 @@ void ProcessedNode::run() {
|
||||
guard.before(get_op_name());
|
||||
}
|
||||
}
|
||||
fn_->f()(this);
|
||||
fn_->run(this);
|
||||
} else {
|
||||
fn_->f()(this);
|
||||
fn_->run(this);
|
||||
}
|
||||
#else
|
||||
fn_->f()(this);
|
||||
fn_->run(this);
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
if (FLAGS_static_runtime_disable_debug_memory_overlap_check) {
|
||||
|
@ -570,8 +570,8 @@ class TORCH_API ProcessedFunction {
|
||||
kInterpreterFallback,
|
||||
};
|
||||
|
||||
const std::function<void(ProcessedNode*)>& f() const {
|
||||
return f_;
|
||||
void run(ProcessedNode* pnode) const {
|
||||
return f_(pnode);
|
||||
}
|
||||
|
||||
Kind kind() const {
|
||||
|
Reference in New Issue
Block a user