buddy-compiler / buddy-benchmark

Benchmark Framework for Buddy Projects
Apache License 2.0
46 stars 39 forks source link

Use conditional compilation to generate Container file based on speci… #30

Closed taiqzheng closed 1 year ago

taiqzheng commented 2 years ago
  1. This commit added MemRef constructor for audio processing.
  1. This commit will generate Container file(both .h and .cpp) according to cmake options.

Note: This scheme(using conditional compilation) may be replaced by inheritance scheme using base class and derived class in future.

axmat commented 2 years ago

@taiqzheng imo MemRef is a templated container so there is no need to use conditional compilation. The compiler does not generate the code for the constructors / member functions if there is no instantiation. For example if you want to use the memref constructor from opencv matrix you need to link the Container and OpenCv, see https://github.com/buddy-compiler/buddy-benchmark/blob/main/benchmarks/DeepLearning/Models/MobileNet-V2/CMakeLists.txt and https://github.com/buddy-compiler/buddy-benchmark/blob/1d0413c509f063b834d2ba2e3b6f4a07e7a242ab/buddy-benchmark.cmake#L18 .

taiqzheng commented 2 years ago

@axmat The original purpose for this commit is adding MemRef for audio processing(to support KFR library), the task was completed but also lead to the inconvenience of using. In the previous work, you need to link OpenCV, Container and KFR(this is the audio library) when solving single task on audio processing. So the problem occured, doing specific work on audio processing( or on image processing), you need to have both OpenCV and KFR installed.

Their were mainly 2 ways to reduce the inconvenience:

  1. using conditional compilation to generate the Container template which contain only the code you need( the task required MemRef and library). This one was completed and became a part of this commit.
  2. using the previous Container as base class, then set 2 derived class( one for image, the other for audio). This solution should be used in the long term, the previous solution in this commit will be replaced.
zhanghb97 commented 1 year ago

The MemRef container in buddy-benchmark will be retired, and we will use the MemRef container in the buddy-mlir.