forked from jiuyuan/InfiniTensor
allocate workspace from allocator for kunlun runtime
This commit is contained in:
parent
e4387904c2
commit
3b7b5740af
|
@ -22,9 +22,9 @@ class KUNLUNRuntimeObj : public RuntimeObj {
|
|||
// 10GB for Longformer
|
||||
// size_t longformerNum = 3lu * (1 << 30);
|
||||
size_t workspaceSize = 3llu << 30; // 3 GB
|
||||
KUNLUNPtr wkspacePtr = alloc(workspaceSize);
|
||||
workspace =
|
||||
make_ref<WorkspaceObj<KUNLUNPtr>>(wkspacePtr, workspaceSize);
|
||||
// KUNLUNPtr wkspacePtr = alloc(workspaceSize);
|
||||
// workspace =
|
||||
// make_ref<WorkspaceObj<KUNLUNPtr>>(wkspacePtr, workspaceSize);
|
||||
}
|
||||
virtual ~KUNLUNRuntimeObj() {
|
||||
KUNLUNPtr wkspacePtr = workspace->getWorkspace();
|
||||
|
@ -33,6 +33,10 @@ class KUNLUNRuntimeObj : public RuntimeObj {
|
|||
}
|
||||
string toString() const override;
|
||||
|
||||
void init_workspace(KUNLUNPtr workspacePtr) {
|
||||
workspace = make_ref<WorkspaceObj<KUNLUNPtr>>(wkspacePtr, workspaceSize);
|
||||
}
|
||||
|
||||
void run(const Graph &graph, bool tune = false,
|
||||
bool profiling = false) const;
|
||||
// double runEvaluation(const Graph &graph, int nWarmups,
|
||||
|
|
|
@ -265,6 +265,11 @@ void GraphObj::dataMalloc(bool useNaiveAllocator, size_t memPoolSize) {
|
|||
tensorToOffset[tensor.get()]));
|
||||
}
|
||||
}
|
||||
|
||||
if (runtime->isKUNLUN()) {
|
||||
allocator.heapAlloc(runtime->workspaceSize);
|
||||
runtime->init_workspace(allocator.getHeapPtr());
|
||||
}
|
||||
}
|
||||
|
||||
Tensor GraphObj::cloneKV(Tensor &tensor) {
|
||||
|
|
Loading…
Reference in New Issue