code: def cast_fp32_to_fp16(exe, main_program):
      """doc"""
      log.info("Cast parameters to float16 data format.")
      for param in main_program.global_block().all_parameters():
          if not param.name.endswith(".master"):
              param_t = (
                  fluid.global_scope().find_var(param.name).get_tensor()
              )
              data = np.array(param_t)
              if (
                  param.name.startswith("encoder_layer")
                  and "layer_norm" not in param.name
              ):
                  param_t.set(
                      np.float16(data).view(np.uint16), exe.place
                  )
  
              # load fp32
              master_param_var = fluid.global_scope().find_var(
                  param.name + ".master"
              )
              if master_param_var is not None:
                  master_param_var.get_tensor().set(data, exe.place)
  
file_path: PGL/ogb_examples/nodeproppred/ogbn-arxiv/GaAN/utils/init.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from __future__ import absolute_import
  import os
  import six
  import ast
  import copy
  import logging
  import numpy
  import paddle.fluid
label_desc: Use image node_id 1 for calling a global function with example usage: cast_fp32_to_fp16(exe, main_program) without return types