hikettei / Caten

[wip] Deep Learning Compiler based on Polyhedral Compiler and Light-weight IRs based on Optimizing Pattern Matcher
https://hikettei.github.io/Caten/
Other
15 stars 1 forks source link

The entire graph compilation and exporter, including Transformer, Tokenizer, Data Loader, weight parser, etc... #144

Open hikettei opened 2 weeks ago

hikettei commented 2 weeks ago

Goal:

hikettei commented 2 weeks ago

something like huggingface trainer (but compilable)

# Workflow of gpt-2 inference
      Input
        |
 [Action: Tokenizer]
        |
  |-[Action:Run]-|
  | Transformer  | <-------------------------------|
  |--------------|                                 |
        |                                          | x N
        |----[Action: Logits Argmax Concatenate] --|
        |    
    [Output]
        |

=>

(defworkflow LLM-Codegen (inputs model)
  ...
   )
hikettei commented 2 weeks ago

Requirements on Action?

hikettei commented 2 weeks ago

WIP: From Common Lisp to Render-Graph Lowerer

(defaction TestFunc (n)
  (declare (type :int64 n))
  (let ((m (* 10 n)))
    (if (> m 1)
        (let ((s (* m 10)))
          s)
        n)))

(defaction Test (x i k)
  (declare (type (:array :row (i k) :float) x)
           (type :int32 i k))
  (setf (aref x 2 2) 2.0)
  (let ((a x))
    (setf (aref a 3 2) 1.0)
    a))

(defaction Matmul (x y z m n k)
  (declare (type (:array :row (m n) :float) x)
           (type (:array :row (n k) :float) y)
           (type (:array :row (m k) :float) z)
           (type :int32 m n k))
  (dotimes (mm m)
    (dotimes (nn n)
      (dotimes (kk k)
        (setf (aref z mm kk) (+ (aref z mm kk) (* (aref x mm nn) (aref y nn kk))))))))