Skip to content

Commit

Permalink
Add runtimeScratchPad info to RuntimeBundle
Browse files Browse the repository at this point in the history
Reviewed By: opti-mix

Differential Revision: D49468217

fbshipit-source-id: 54c366d38a3abbf647f578d3b65085e4b6f720ed
  • Loading branch information
Junhan Hu authored and facebook-github-bot committed Sep 21, 2023
1 parent a441edb commit b06a601
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/glow/Backend/BackendUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class RuntimeBundle {
size_t mutableWeightVarsMemSize_{0};
/// Amount of memory needed for activations.
size_t activationsMemSize_{0};
/// Amount of memory needed for runtime scratch pad.
size_t runtimeScratchPadMemSize_{0};
/// True if the RuntimeBundle is valid, false if not.
bool isValid_{false};

Expand All @@ -97,6 +99,10 @@ class RuntimeBundle {
void updateSymbolTable(const SymbolTableTy &symbolTable) {
symbolTable_ = symbolTable;
}
void setRuntimeScratchPadSize(const size_t s) {
runtimeScratchPadMemSize_ = s;
}
size_t getRuntimeScratchPadSize() const { return runtimeScratchPadMemSize_; }
/// At compile time condense constants to a single block of memory.
/// This allows the graph to go away after compile time.
/// Allocates a block of memory of size \p constantMaxSize then walks the
Expand Down Expand Up @@ -153,6 +159,15 @@ class RuntimeBundle {
mutableWeightVarsMemSize_(mutableWeight),
activationsMemSize_(activations), isValid_(true) {}

RuntimeBundle(SymbolTableTy &symbolTable, size_t constWeight,
size_t mutableWeight, size_t activations,
size_t runtimeScratchPad)
: symbolTable_(std::move(symbolTable)), constants_(nullptr),
constantWeightVarsMemSize_(constWeight),
mutableWeightVarsMemSize_(mutableWeight),
activationsMemSize_(activations),
runtimeScratchPadMemSize_(runtimeScratchPad), isValid_(true) {}

// Explicit copy constructor and deleted assignment operator. A RuntimeBundle
// should be moved. It should only be copied if absolutely necessary and never
// implicitly.
Expand Down
2 changes: 2 additions & 0 deletions include/glow/LLVMIRCodeGen/LLVMIRGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class LLVMIRGen {
llvm::Value *baseConstantWeightVarsAddr_{nullptr};
/// Value holding the base address of mutable WeightVars memory area.
llvm::Value *baseMutableWeightVarsAddr_{nullptr};
/// Value holding the base address of runtime scratch pad.
llvm::Value *baseRuntimeScratchPadAddr_{nullptr};
/// Value holding the address of the offsets array.
llvm::Value *offsetsArray_{nullptr};
/// Maps constant arrays to the constant expressions representing size_t
Expand Down
1 change: 1 addition & 0 deletions lib/Backend/BackendUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ glow::runtime::RuntimeBundle::operator=(glow::runtime::RuntimeBundle &&rhs) {
std::swap(constantWeightVarsMemSize_, rhs.constantWeightVarsMemSize_);
std::swap(mutableWeightVarsMemSize_, rhs.mutableWeightVarsMemSize_);
std::swap(activationsMemSize_, rhs.activationsMemSize_);
std::swap(runtimeScratchPadMemSize_, rhs.runtimeScratchPadMemSize_);
std::swap(isValid_, rhs.isValid_);
// rhs is not valid now that all of its contents have been stolen.
rhs.isValid_ = false;
Expand Down

0 comments on commit b06a601

Please sign in to comment.