# -*- coding: utf8 -*-
import os
from utensor_cgen.utils import save_consts, save_graph, save_idx
import numpy as np
import tensorflow as tf


def generate():
  test_dir = os.path.dirname(__file__)
  graph = tf.Graph()
  with graph.as_default():
    x = tf.constant(np.random.randn(10),
                    dtype=tf.float32,
                    name='x')
    output_x = tf.reshape(x, [5, 2], name="output_x")

  with tf.Session(graph=graph) as sess:
    save_consts(sess, test_dir)
    save_graph(graph, 'test_reshape_4', test_dir)
    np_output = output_x.eval()
    save_idx(np_output, os.path.join(test_dir, 'output_x.idx'))
  # test_reshape_4.pb is the same as test_quant_reshape_4.pb
  # hack, since we do not have QuantizedReshape yet

if __name__ == "__main__":
  generate()

[((9, 13, 9, 38), 'os.path.dirname', 'os.path.dirname', ({(9, 29, 9, 37): '__file__'}, {}), '(__file__)', False, 'import os\n'), ((10, 10, 10, 20), 'tensorflow.Graph', 'tf.Graph', ({}, {}), '()', True, 'import tensorflow as tf\n'), ((15, 15, 15, 53), 'tensorflow.reshape', 'tf.reshape', (), '', True, 'import tensorflow as tf\n'), ((17, 7, 17, 30), 'tensorflow.Session', 'tf.Session', (), '', True, 'import tensorflow as tf\n'), ((18, 4, 18, 31), 'utensor_cgen.utils.save_consts', 'save_consts', ({(18, 16, 18, 20): 'sess', (18, 22, 18, 30): 'test_dir'}, {}), '(sess, test_dir)', False, 'from utensor_cgen.utils import save_consts, save_graph, save_idx\n'), ((19, 4, 19, 49), 'utensor_cgen.utils.save_graph', 'save_graph', ({(19, 15, 19, 20): 'graph', (19, 22, 19, 38): '"""test_reshape_4"""', (19, 40, 19, 48): 'test_dir'}, {}), "(graph, 'test_reshape_4', test_dir)", False, 'from utensor_cgen.utils import save_consts, save_graph, save_idx\n'), ((12, 20, 12, 39), 'numpy.random.randn', 'np.random.randn', ({(12, 36, 12, 38): '10'}, {}), '(10)', True, 'import numpy as np\n'), ((21, 24, 21, 62), 'os.path.join', 'os.path.join', ({(21, 37, 21, 45): 'test_dir', (21, 47, 21, 61): '"""output_x.idx"""'}, {}), "(test_dir, 'output_x.idx')", False, 'import os\n')]