--- /dev/null
+#ifndef NNCC_CAFFE_VISITOR_H
+#define NNCC_CAFFE_VISITOR_H
+
+#include "caffe/proto/caffe.pb.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace frontend
+{
+namespace caffe
+{
+
+using namespace ::caffe;
+
+class Visitor
+{
+public:
+ virtual ~Visitor() = default;
+
+ virtual void visit(const NetParameter&) = 0;
+ virtual void visit(const LayerParameter&) = 0;
+ virtual void visit(const BlobProto&) = 0;
+ virtual void visit(const BlobShape&) = 0;
+};
+
+} // namespace caffe
+} // namespace frontend
+} // namespace contrib
+} // namespace nncc
+
+#endif //NNCC_CAFFE_VISITOR_H
--- /dev/null
+#ifndef NNCC_CAFFE_WALKER_H
+#define NNCC_CAFFE_WALKER_H
+
+#include "caffe/proto/caffe.pb.h"
+
+#include "caffe_visitor.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace frontend
+{
+namespace caffe
+{
+
+using namespace ::caffe;
+
+class ModelWalker
+{
+public:
+ ModelWalker(Visitor* visitor) : visitor(visitor) {};
+
+ void walkNetParameter(const NetParameter&);
+ void walkLayerParameter(const LayerParameter&);
+
+private:
+ Visitor* visitor;
+};
+
+} // namespace caffe
+} // namespace frontend
+} // namespace contrib
+} // namespace nncc
+
+#endif // NNCC_CAFFE_WALKER_H
--- /dev/null
+#include "caffe_walker.h"
+
+namespace nncc
+{
+namespace contrib
+{
+namespace frontend
+{
+namespace caffe
+{
+
+void ModelWalker::walkNetParameter(const NetParameter& np)
+{
+ visitor->visit(np);
+
+ for (int i = 0; i < np.layer_size(); ++i)
+ {
+ walkLayerParameter(np.layer(i));
+ }
+
+ for (int i = 0; i < np.input_shape_size(); ++i)
+ {
+ visitor->visit(np.input_shape(i));
+ }
+}
+
+void ModelWalker::walkLayerParameter(const LayerParameter& lp)
+{
+ visitor->visit(lp);
+
+ for (int i = 0; i < lp.blobs_size(); ++i)
+ {
+ visitor->visit(lp.blobs(i));
+ }
+}
+
+} // namespace caffe
+} // namespace frontend
+} // namespace contrib
+} // namespace nncc