mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[nativert] move layout planner settings to torch (#154668)
Summary: att Test Plan: ci Differential Revision: D75633031 Pull Request resolved: https://github.com/pytorch/pytorch/pull/154668 Approved by: https://github.com/zhxchen17
This commit is contained in:
83
torch/nativert/executor/memory/LayoutPlannerSettings.h
Normal file
83
torch/nativert/executor/memory/LayoutPlannerSettings.h
Normal file
@ -0,0 +1,83 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace torch::nativert {
|
||||
|
||||
enum class LayoutPlannerAlgorithmType {
|
||||
Bump,
|
||||
GreedyBySize,
|
||||
};
|
||||
|
||||
class LayoutManagerSettings {
|
||||
public:
|
||||
LayoutManagerSettings() = default;
|
||||
|
||||
bool deallocateBetweenRequests() const {
|
||||
return deallocateBetweenRequests_;
|
||||
}
|
||||
|
||||
LayoutManagerSettings& setDeallocateBetweenRequests(
|
||||
bool deallocateBetweenRequests) {
|
||||
deallocateBetweenRequests_ = deallocateBetweenRequests;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class LayoutManager;
|
||||
bool deallocateBetweenRequests_{true};
|
||||
};
|
||||
|
||||
class LayoutPlannerSettings {
|
||||
public:
|
||||
LayoutPlannerSettings() = default;
|
||||
|
||||
bool enabled() const {
|
||||
return enabled_;
|
||||
}
|
||||
|
||||
LayoutPlannerAlgorithmType algorithmType() const {
|
||||
return layoutPlannerAlgorithmType_;
|
||||
}
|
||||
|
||||
std::chrono::seconds planningInterval() const {
|
||||
return planningInterval_;
|
||||
}
|
||||
|
||||
const LayoutManagerSettings& layoutManagerSettings() const {
|
||||
return layoutManagerSettings_;
|
||||
}
|
||||
|
||||
LayoutPlannerSettings& setEnabled(bool enabled) {
|
||||
enabled_ = enabled;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LayoutPlannerSettings& setAlgorithmType(
|
||||
LayoutPlannerAlgorithmType layoutPlannerAlgorithmType) {
|
||||
layoutPlannerAlgorithmType_ = layoutPlannerAlgorithmType;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LayoutPlannerSettings& setPlanningInterval(
|
||||
std::chrono::seconds planningInterval) {
|
||||
planningInterval_ = planningInterval;
|
||||
return *this;
|
||||
}
|
||||
|
||||
LayoutPlannerSettings& setLayoutManagerSettings(
|
||||
LayoutManagerSettings layoutManagerSettings) {
|
||||
layoutManagerSettings_ = layoutManagerSettings;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class LayoutPlanner;
|
||||
bool enabled_{false};
|
||||
LayoutPlannerAlgorithmType layoutPlannerAlgorithmType_{
|
||||
LayoutPlannerAlgorithmType::Bump};
|
||||
std::chrono::seconds planningInterval_{5};
|
||||
LayoutManagerSettings layoutManagerSettings_;
|
||||
};
|
||||
|
||||
} // namespace torch::nativert
|
Reference in New Issue
Block a user