@register_opt()
@local_optimizer([SparseBlockOuter, GpuFromHost])
def gpu_sparse_block_outer_opt(node):
 if (isinstance(node.op, SparseBlockOuter) and any((_owner_isinstance(inp, HostFromGpu) for inp in node.inputs))):
  inputs = _clear_host_from_gpu(node.inputs)
  return [host_from_gpu(GpuSparseBlockOuter()(*inputs))]
 elif (isinstance(node.op, GpuFromHost) and _owner_isinstance(node.inputs[0], SparseBlockOuter)):
  meta_node = node.inputs[0].owner
  inputs = _clear_host_from_gpu(meta_node.inputs)
  return [GpuSparseBlockOuter()(*inputs)]

@ register_opt ( ) @ local_optimizer ( [ SparseBlockOuter , GpuFromHost ] ) def gpu_sparse_block_outer_opt ( node ) : if ( isinstance ( node . op , SparseBlockOuter ) and any ( ( _owner_isinstance ( inp , HostFromGpu ) for inp in node . inputs ) ) ) : inputs = _clear_host_from_gpu ( node . inputs ) return [ host_from_gpu ( GpuSparseBlockOuter ( ) ( * inputs ) ) ] elif ( isinstance ( node . op , GpuFromHost ) and _owner_isinstance ( node . inputs [ 0 ] , SparseBlockOuter ) ) : meta_node = node . inputs [ 0 ] . owner inputs = _clear_host_from_gpu ( meta_node . inputs ) return [ GpuSparseBlockOuter ( ) ( * inputs ) ]
sparseblockouter(hostfromgpu) -> hostfromgpu(gpusparseblockouter) or gpufromhost -> gpusparseblockouter .