message: Update perf_example to use TF2 features
  Summary: TF2.1 Only
  Reviewers: #tensorflow, #framework_ip_review_-_any_oss_or_third-party_code_use_has_been_approved, #documentation, jamiep, georgep, hakons
  Subscribers: grahamh, hakons, georgep, jamiep
  Maniphest Tasks: T29292
diff: -from tensorflow.python.ipu import ipu_compiler
  from tensorflow.python.ipu import ipu_infeed_queue
  from tensorflow.python.ipu import ipu_outfeed_queue
  from tensorflow.python.ipu import loops
  -from tensorflow.python.ipu import scopes
  from tensorflow.python.ipu import utils
  -import tensorflow.compat.v1 as tf
  -tf.disable_v2_behavior()
  +from tensorflow.python.ipu import ipu_strategy
  +import tensorflow as tf
  # The dataset for feeding the graphs
  ds = tf.data.Dataset.from_tensors(tf.constant(1.0, shape=[800]))
  @@ -18,32 +16,35 @@ outfeed_queue = ipu_outfeed_queue.IPUOutfeedQueue(feed_name="outfeed")
  # The device side main
  -def body(x1, x2):
  +def body(counter, x1, x2):
  d1 = x1 + x2
  d2 = x1 - x2
  - outfeed = outfeed_queue.enqueue({'d1': d1, 'd2': d2})
  - return outfeed
  + counter += 1
  + outfeed_queue.enqueue({'d1': d1, 'd2': d2})
  + return counter
  +@tf.function(experimental_compile=True)
  def my_net():
  - r = loops.repeat(10, body, [], infeed_queue)
  - return r
  + count = 0
  + count = loops.repeat(10, body, [count], infeed_queue)
  + return count
  -with scopes.ipu_scope('/device:IPU:0'):
  - run_loop = ipu_compiler.compile(my_net, inputs=[])
  -
  -# The outfeed dequeue has to happen after the outfeed enqueue
  -dequeue_outfeed = outfeed_queue.dequeue()
  -
  -# Configure the hardware
  +# Configure the hardware.
  config = utils.create_ipu_config()
  config = utils.auto_select_ipus(config, 1)
  utils.configure_ipu_system(config)
  -with tf.Session() as sess:
  - sess.run(infeed_queue.initializer)
  +# Initialize the IPU default strategy.
  +strategy = ipu_strategy.IPUStrategy()
  +
  +with strategy.scope():
  + infeed_queue.initializer
  + count_out = strategy.experimental_run_v2(my_net)
  + print("counter", count_out)
  +
  + # The outfeed dequeue has to happen after the outfeed enqueue op has been executed.
  + result = outfeed_queue.dequeue()
  - sess.run(run_loop)
  - result = sess.run(dequeue_outfeed)
  - print(result)
  + print("outfeed result", result)
  