You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: wsinterpd2.m
    path of file: ./repos/qups/kern
    
    the code of the file until where you have to start completion: function y = wsinterpd2(x, t1, t2, dim, w, sdim, interp, extrapval, omega)
% WSINTERPD2 GPU-enabled weight-and-sum interpolation in one dimension with
% 2 delay inputs
%
% y = WSINTERPD2(x, t1, t2) interpolates the data x at the indices 
% t = t1 + t2. It uses the matching and non-matching dimensions of the data
% to implicitly broadcast operations across the data. In other words, the
% data is formatted into the following:
%
%   x is (T x N' x      F')
%   t is (I x N' x M'     )
%   y is (I x N' x M' x F')
%
% Defining t1 and t2 separately allows 
    
function to determine type
isftype = @(x,T) strcmp(class(x), T) || any(arrayfun(@(c)isa(x,c),["tall", "gpuArray"])) && strcmp(classUnderlying(x), T);

% use ptx on gpu if available or use native MATLAB
if exist('interpd.ptx', 'file') ...
        && ( isa(x, 'gpuArray') || isa(t1, 'gpuArray') || isa(t2, 'gpuArray') || isa(x, 'halfT') && x.gtype) ...
        && (ismember(interp, ["nearest", "linear", "cubic", "lanczos3"])) ... 
        && real(omega) == 0

    % get stride for weighting
    wstride = sz2stride(size(w,1:S));

    % get stride for data
    xstride = sz2stride([1 size(x,2:S)]); % treat as singular in dim 1

    % get stride for time
    t1stride = sz2stride(size(t1,1:S));
    t2stride = sz2stride(size(t2,1:S));

    % get stride for output
    osz = dsizes; osz(sdim) = 1; % these dimensions are summed
    ystride = sz2stride(osz);

    % determine the data type
    if     isftype(x, 'double')
        suffix = "" ; [x,t1,t2,w] = dealfun(@double, x, t1, t2, w);
    elseif isftype(x, 'single')
        suffix = "f"; [x,t1,t2,w] = dealfun(@single, x, t1, t2, w);
    elseif isftype(x, 'halfT'  )
        suffix = "h"; [x,t1,t2,w] = dealfun(@(x)gpuArray(halfT(x)), x, t1, t2, w); % custom type
    else
        warning("Datatype " + class(x) + " not recognized as a GPU compatible type.");
        suffix = "f" ;
    end