tvm-clj.application.image
Image resize algorithm showing somewhat nontrivial application of TVM operators. In this case we have an algorithm which is a simple average area color algorithm used for scaling images down. This reads a rectangle in the source image and averages it for every destination pixel.
This is a namespace where you want to view the source :-)
(def input-img (bufimg/load "test/data/jen.jpg"))
(def test-fn (-> (tvm-area-resize-algo-def)
(schedule-tvm-area)
(compile-scheduled-tvm-area)))
(def result (time (area-resize! input-img 512 test-fn)))
;;179 ms
(def jvm-result (time (area-resize! input-img 512 jvm-area-resize-fn!)))
;;5.7 seconds
area-resize!
(area-resize! input new-width resize-fn)
Perform an area resize with a defined resize algorithm.
tvm-area-resize-algo
(tvm-area-resize-algo n-channels device-type)
Step 1 is to define the algorithm. This definition looks strikingly similar to the definition above.