code: def test_opencl_ternary_expression():
      def check_if_then_else(dev, n, dtype):
          A = te.placeholder((n,), name="A", dtype=dtype)
          true_value = tvm.tir.const(1, dtype=dtype)
          false_value = tvm.tir.const(3, dtype=dtype)
          max_lhs = tvm.tir.const(2, dtype=dtype)
          max_rhs = tvm.tir.if_then_else(
              A[0] > 0, true_value, false_value
          )
          C = te.compute(
              (n,), lambda i: tvm.te.max(max_lhs, max_rhs), name="C"
          )
  
          func = te.create_prim_func([A, C])
          sch = tvm.tir.Schedule(func)
          (x,) = sch.get_loops(sch.get_block("C"))
          sch.bind(x, "threadIdx.x")
          fun = tvm.build(sch.mod, target=target)
          a = tvm.nd.empty((n,), A.dtype, dev)
          c = tvm.nd.empty((n,), A.dtype, dev)
          # Only need to test compiling here
          fun(a, c)
  
      def check_select(dev, n, dtype):
          A = te.placeholder((n,), name="A", dtype=dtype)
          true_value = tvm.tir.const(1, dtype=dtype)
          false_value = tvm.tir.const(3, dtype=dtype)
          max_lhs = tvm.tir.const(2, dtype=dtype)
          max_rhs = tvm.tir.Select(A[0] > 0, true_value, false_value)
          C = te.compute(
              (n,), lambda i: tvm.te.max(max_lhs, max_rhs), name="C"
          )
          func = te.create_prim_func([A, C])
          sch = tvm.tir.Schedule(func)
          (x,) = sch.get_loops(sch.get_block("C"))
          sch.bind(x, "threadIdx.x")
          fun = tvm.build(sch.mod, target=target)
  
          a = tvm.nd.empty((n,), A.dtype, dev)
          c = tvm.nd.empty((n,), A.dtype, dev)
          # Only need to test compiling here
          fun(a, c)
  
      dev = tvm.device(target, 0)
  
      check_if_then_else(dev, 1, "int8")
      check_if_then_else(dev, 1, "uint8")
      check_if_then_else(dev, 1, "int16")
      check_if_then_else(dev, 1, "uint16")
      check_select(dev, 1, "int8")
      check_select(dev, 1, "uint8")
      check_select(dev, 1, "int16")
      check_select(dev, 1, "uint16")
  
file_path: tvm/tests/python/codegen/test_target_codegen_opencl.py
imports: import tvm
  from tvm import te, relay
  import tvm.testing
  import re
  import pytest
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: test_opencl_ternary_expression() without return types