                      :op :mul
                      }
                :add1 {
-                      :op :add
+                      :op :mul
                       }
                :add2 {
                       :op :add
                       }
                }
    })
-
-
-{:node [{:name "Const",
-         :op "Const",
-         :attr [{:key "value", :value {:tensor {:dtype :dt-float, :tensor-shape {}, :float-val [3.0]}}}
-                {:key "dtype", :value {:type :dt-float}}]}
-        {:name "Placeholder",
-         :op "Placeholder",
-         :attr [{:key "dtype", :value {:type :dt-float}} {:key "shape", :value {:shape {}}}]}
-        {:name "mul", :op "Mul", :input ["Const" "Placeholder"], :attr [{:key "T", :value {:type :dt-float}}]}],
- :versions {:producer 21}}
 
 (defn build-node-def [node-name-map inputs-map key entry]
   (let [attr (case (-> entry :op)

  (let [keys (map second inputs)]
    (zipmap keys (map first inputs))))

(defn build-tf-graph [graph-def]
  (let [{:keys [inputs outputs mappings node-defs]} graph-def
        node-keys (keys node-defs)
        node-name-map (zipmap node-keys (map #(-> % name gen-name) node-keys))
        inputs-map (build-inputs-map mappings)
        node-defs (map #(apply (partial build-node-def node-name-map inputs-map) %) node-defs)]
    {:node node-defs


(build-tf-graph example-graph)

(defn graph-to-bytes [graph]
  (let [proto-graph (apply
                      (partial proto/protobuf proto-graph-def)
                      (->> graph
                           (into [])
                           (apply concat)))]
    (proto/protobuf-dump proto-graph)))

(def linreg-graph (proto/protobuf-load proto-graph-def (util/slurp-binary "misc/linreg.pb")))
(-> linreg-graph :node count)
(map :name (-> linreg-graph :node))

(def addconst-graph (proto/protobuf-load proto-graph-def (util/slurp-binary "misc/addconst.pb")))
(-> addconst-graph :node count)

{:node [{:name "Const",
         :op "Const",
         :attr [{:key "value", :value {:tensor {:dtype :dt-float, :tensor-shape {}, :float-val [3.0]}}}
                {:key "dtype", :value {:type :dt-float}}]}
        {:name "Placeholder",
         :op "Placeholder",
         :attr [{:key "dtype", :value {:type :dt-float}} {:key "shape", :value {:shape {}}}]}
        {:name "mul", :op "Mul", :input ["Const" "Placeholder"], :attr [{:key "T", :value {:type :dt-float}}]}],
 :versions {:producer 21}}

(exp/exec-graph-sess-fn
  (fn [graph session]
    ;(.importGraphDef graph (util/slurp-binary "misc/addconst.pb"))
    ;(.importGraphDef graph (proto/protobuf-dump addconst-graph))
    (.importGraphDef graph (graph-to-bytes (build-tf-graph example-graph)))
    (exp/run-graph-thing session  {:in1 (float 3.0) :in2 (float 3.0)} :mul)))
