code: def test_float16():
      # gemv (gemm called)
      float16_data = [
          rand(3).astype("float16"),
          np.asarray(1, dtype=np.float32),
          rand(3, 3).astype("float16"),
          rand(3).astype("float16"),
          np.asarray(0.5, dtype=np.float32),
      ]
      float16_shared = [
          gpuarray_shared_constructor(val, target=test_ctx_name)
          for val in float16_data
      ]
      o = gemv(*float16_shared)
      f = theano.function([], o, mode=mode_with_gpu)
      y, alpha, A, x, beta = float16_data
      out = f()
      utt.assert_allclose(
          np.asarray(out), alpha * np.dot(A, x) + beta * y
      )
      topo = f.maker.fgraph.toposort()
      assert any([isinstance(n.op, GpuGemm) for n in topo])
  
      # gemm
      float16_data = [
          rand(3, 3).astype("float16"),
          np.asarray(1, dtype=np.float32),
          rand(3, 3).astype("float16"),
          rand(3, 3).astype("float16"),
          np.asarray(0.5, dtype=np.float32),
      ]
      float16_shared = [
          gpuarray_shared_constructor(val, target=test_ctx_name)
          for val in float16_data
      ]
      o = gpugemm_no_inplace(*float16_shared)
      f = theano.function([], o)
      y, alpha, A, x, beta = float16_data
      out = f()
      utt.assert_allclose(
          np.asarray(out), alpha * np.dot(A, x) + beta * y
      )
  
      # dot22
      float16_data = [
          rand(3, 3).astype("float16"),
          rand(3, 3).astype("float16"),
      ]
  
      float16_shared = [
          gpuarray_shared_constructor(val) for val in float16_data
      ]
      o = gpu_dot22(*float16_shared)
      f = theano.function([], o)
      x, y = float16_data
      out = f()
      utt.assert_allclose(np.asarray(out), np.dot(x, y))
  
imports: from __future__ import absolute_import, print_function, division
  from unittest import TestCase
  from nose.plugins.skip import SkipTest
  import itertools
  import numpy
  import theano
  from theano import config
  from theano import tensor
  from theano.tests import unittest_tools
  from theano.tensor.blas import gemv, gemv_inplace, gemm_inplace, _dot22, batched_dot
  from theano.tensor.tests.test_blas import TestGer, BaseGemv
  from ..None import gpuarray_shared_constructor
  from .config import mode_with_gpu, test_ctx_name
  from .test_basic_ops import makeTester, rand
  from ..blas import gpugemv_inplace, gpugemv_no_inplace, gpugemm_inplace, gpugemm_no_inplace, gpugemmbatch_inplace, gpuger_inplace, gpuger_no_inplace, GpuGer, GpuGemm, gpu_dot22
label_desc: Use image node_id 1 for calling a global function with example usage: test_float16() without return types