import tensorflow as tf

      for t in threads:
        t.join()

      vals = p.eval()
      ones = np.ones((1024, 1024)).astype(np.float32)
      self.assertTrue((vals >= ones).all())
      self.assertTrue((vals <= ones * 20).all())

  def testParallelAssignWithoutLocking(self):
    with self.test_session() as sess:
      ones_t = tf.fill([1024, 1024], float(1))
      p = tf.Variable(tf.zeros([1024, 1024]))
      assigns = [tf.assign(p, tf.mul(ones_t, float(i)), False)
                 for i in range(1, 21)]
      tf.initialize_all_variables().run()

      def run_assign(assign_op):
        sess.run(assign_op)
      threads = [self.checkedThread(target=run_assign, args=(assign_op,))
                 for assign_op in assigns]
      for t in threads:
        t.start()
