parameters: (img, max_val)
return_statement: return ret
docstring: convert img dtype to float32
docstring_summary: convert img dtype to float32
docstring_tokens: convert img dtype to float32
function: def _convert_img_dtype_to_float32(img, max_val):
      """convert img dtype to float32"""
      # Usually max_val is 1.0 or 255, we will do the scaling if max_val > 1.
      # We will scale img pixel value if max_val > 1. and just cast otherwise.
      ret = F.cast(img, mstype.float32)
      max_val = F.scalar_cast(max_val, mstype.float32)
      if max_val > 1.:
          scale = 1. / max_val
          ret = ret * scale
      return ret
function_tokens: def _convert_img_dtype_to_float32 ( img , max_val ) : # Usually max_val is 1.0 or 255, we will do the scaling if max_val > 1. # We will scale img pixel value if max_val > 1. and just cast otherwise. ret = F . cast ( img , mstype . float32 ) max_val = F . scalar_cast ( max_val , mstype . float32 ) if max_val > 1. : scale = 1. / max_val ret = ret * scale return ret