
출처: datacenterfrontier.com
인텔에서 새로운 딥러닝 칩인 DLIA(Deep Learning Inference Accelerator)와 딥러닝 프레임워크 너바나 그래프(Nervana Graph) 를 발표(datacenterfrontier, nervanasys)했습니다. DLIA는 일전에 마이크로소프트가 발표했던 Catapult 처럼 FPGA 방식입니다. 이름에서 알 수 있듯이 모델 학습이 아니고 추론(Inference)에 맞춰져 개발되었습니다.

출처: nervanasys.com
너바나 그래프(ngraph)는 프론트엔드, ngraph API, 트랜스포머 세 부분으로 구성되어 있다고 합니다. 너바나 그래프의 큰 특징은 여러 딥러닝 프레임워크의 API 를 그대로 사용해서 그래프를 만들면 이를 트랜스포머를 사용하여 변환한 후 여러 하드웨어에 맞추어 실행시킬 수 있는 점입니다. 현재 프리 릴리즈에서 제공하는 프론트엔드는 너바나시스템즈의 네온(neon) 프레임워크와 구글의 텐서플로우 입니다. 아직 텐서플로우의 모든 API 를 지원하지는 않습니다만 아마도 빠르게 개발이 진행될 것으로 보입니다. 아래는 텐서플로우로 만든 그래프를 트랜스포머로 변경하여 실행시키는 간단한 예제 중 일부 코드입니다.
# write tensorflow models x = tf.placeholder(tf.float32, [args.batch_size, 784]) t = tf.placeholder(tf.float32, [args.batch_size, 10]) w = tf.Variable(tf.zeros([784, 10])) b = tf.Variable(tf.zeros([10])) y = tf.matmul(x, w) + b cost = tf.reduce_mean(-tf.reduce_sum(t * tf.log(tf.nn.softmax(y)), reduction_indices=[1])) init = tf.initialize_all_variables() # import graph_def with tf.Session() as sess: graph_def = sess.graph_def importer = TFImporter() importer.parse_graph_def(graph_def) # get handle of ngraph ops x_ng, t_ng, cost_ng, init_op_ng = importer.get_op_handle([x, t, cost, init]) # transformer and computations transformer = ngt.make_transformer() updates = SGDOptimizer(args.lrate).minimize(cost_ng) train_comp = transformer.computation([cost_ng, updates], x_ng, t_ng) init_comp = transformer.computation(init_op_ng) transformer.initialize() # train mnist = input_data.read_data_sets(args.data_dir, one_hot=True) init_comp() for idx in range(args.max_iter): batch_xs, batch_ys = mnist.train.next_batch(args.batch_size) cost_val, _ = train_comp(batch_xs, batch_ys) print("[Iter %s] Cost = %s" % (idx, cost_val))
위 코드에서 importer.parse_graph_def
대신 importer.parse_protobuf
를 사용하면 텐서플로우의 SummaryWriter
로 저장한 모델을 불러서 임포트 시킬 수 있다고 합니다. 즉 다른 사람이 만든 그래프를 코드 레벨이 아니고 데이터 레벨로 공유 받아서 ngraph 를 실행시킬 수 있습니다. ngraph 의 또 하나의 재미있는 특징은 텐서의 차원에 네이밍을 하여 재사용 가능한 Axis 를 도입한 점입니다. 딥러닝 모델들이 텐서의 차원을 맞추는 귀찮니즘을 동반하고 있다는 걸 잘 캐치한 것 같습니다.
인텔은 작년에 FPGA 분야의 선두 업체인 알테라(Altera)를 인수했고 지난 8월에는 너바나(Nervana) 시스템즈를 인수하였습니다. DLIA 와 ngraph 는 그 이후에 내놓는 첫 결과물인 것 같습니다. 앞으로는 인텔이 칩 분야 뿐만 아니라 프레임워크에서도 어떤 성과를 내놓을지 기대를 해봐도 좋을 것 같습니다.