Fix: add virutal method sync in Runtime

This commit is contained in:
Liyan Zheng 2023-04-28 00:44:54 +08:00
parent c58b67f743
commit 95a8b90fa7
5 changed files with 5 additions and 4 deletions

View File

@ -36,7 +36,7 @@ class BangRuntimeObj : public RuntimeObj {
bool profiling = false) const; bool profiling = false) const;
// double runEvaluation(const Graph &graph, int nWarmups, // double runEvaluation(const Graph &graph, int nWarmups,
// int nEvaluations) const; // int nEvaluations) const;
void sync() const; void sync() const override;
BangPtr alloc(size_t size) override { BangPtr alloc(size_t size) override {
void *ptr; void *ptr;
checkBangError(cnrtMalloc(&ptr, size)); checkBangError(cnrtMalloc(&ptr, size));

View File

@ -79,6 +79,7 @@ class RuntimeObj : public std::enable_shared_from_this<RuntimeObj> {
virtual void copyBlobToCPU(void *dst, const void *src, virtual void copyBlobToCPU(void *dst, const void *src,
size_t bytes) const = 0; size_t bytes) const = 0;
virtual string toString() const = 0; virtual string toString() const = 0;
virtual void sync() const {}
map<UidBaseType, bool> map<UidBaseType, bool>
getCompileTimeComputableAttribute(const Graph &graph) const; getCompileTimeComputableAttribute(const Graph &graph) const;

View File

@ -27,7 +27,7 @@ class CudaRuntimeObj : public RuntimeObj {
bool profiling = false) const; bool profiling = false) const;
// double runEvaluation(const Graph &graph, int nWarmups, // double runEvaluation(const Graph &graph, int nWarmups,
// int nEvaluations) const; // int nEvaluations) const;
void sync() const; void sync() const override;
CudaPtr alloc(size_t size) override { CudaPtr alloc(size_t size) override {
void *ptr; void *ptr;
// printf("Try to cudaMalloc: %lu bytes\n", size); // printf("Try to cudaMalloc: %lu bytes\n", size);

View File

@ -29,7 +29,7 @@ class MklRuntimeObj : public CpuRuntimeObj {
string toString() const override { return "INTELCPU Runtime"; }; string toString() const override { return "INTELCPU Runtime"; };
dnnl::engine getEngine() const { return dnnl::engine(engine, true); } dnnl::engine getEngine() const { return dnnl::engine(engine, true); }
dnnl::stream getStream() const { return dnnl::stream(stream, true); } dnnl::stream getStream() const { return dnnl::stream(stream, true); }
void sync() const; void sync() const override;
}; };
} // namespace infini } // namespace infini

View File

@ -241,7 +241,7 @@ double RuntimeObj::timeNonCtcOperators(const Graph &graph, int warmup,
kernel->compute(op, this); kernel->compute(op, this);
} }
}, },
[&]() { sync(); }, warmup, repeat); [&]() { this->sync(); }, warmup, repeat);
return ret; return ret;
} }