2022-09-18 20:27:18 +08:00
|
|
|
#pragma once
|
|
|
|
#include "core/kernel.h"
|
|
|
|
#include "cuda/cuda_runtime.h"
|
|
|
|
|
|
|
|
namespace infini {
|
|
|
|
|
|
|
|
class CudaKernelWithoutConfig : public Kernel {
|
|
|
|
public:
|
|
|
|
virtual void compute(const Operator &op, const PerfRecord &record,
|
|
|
|
const RuntimeObj *context) const {
|
|
|
|
compute(op, context);
|
|
|
|
}
|
|
|
|
virtual void compute(const Operator &op,
|
|
|
|
const RuntimeObj *context) const = 0;
|
|
|
|
// Premise: op is idempotent since it is called multiple times.
|
|
|
|
virtual PerfRecord tune(const Operator &op,
|
|
|
|
const RuntimeObj *_context) const {
|
|
|
|
auto context = dynamic_cast<const CudaRuntimeObj *>(_context);
|
|
|
|
return make_ref<PerfRecordObj>(timeit([&]() { compute(op, _context); },
|
|
|
|
[&]() { context->sync(); }));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-10-15 16:29:28 +08:00
|
|
|
} // namespace infini
|