Sha256: 6fcfbb41dfc5af1ba304b1ac0bdda4b1e20eaa9639c2c1061c8f7e0a29eb7724

Contents?: true

Size: 1007 Bytes

Versions: 13

Compression:

Stored size: 1007 Bytes

Contents

% ctype = dtype_to_c_type(data_type)

__kernel void unpack(const int N, const int index, __global const <%= ctype %> *A, __global <%= ctype %> *C) {
    // Get the index of the current element to be processed
    const int globalCol = get_global_id(0); // Col ID of C (0..N)

    int start = index * <%= divisors[0] %>;
    int ptr = start + globalCol;
    int index_map[<%= divisors.size %>] = { <%= Array.new(divisors.size) { 0 }.join(', ') %> };

    // compute effective coordinates
<% divisors.each_with_index do |div, index| %>
    index_map[<%= index %>] = (int)floor(ptr / (float)<%= div %>);<% if index < divisors.size - 1%>ptr = ptr % <%= div %>;<% end %><% end %>

    // Apply axis translation if needed
<% if axis > 0 %>
    int last = index_map[<%= axis %>];
<% axis.downto(1) do |i| %> index_map[<%= i %>] = index_map[<%= (i - 1) %>];<% end %>
    index_map[0] = last;
<% end%>

    C[<%= multipliers.each_with_index.map { |m, idx| "#{m}*index_map[#{idx}]" }.join(' + ') %>] = A[globalCol];
}

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
tensor_stream-opencl-0.3.2 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.3.1 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.3.0 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.10 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.9 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.8 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.6 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.5 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.4 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.3 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.2 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.1 lib/tensor_stream/opencl/kernels/unpack.cl
tensor_stream-opencl-0.2.0 lib/tensor_stream/opencl/kernels/unpack.cl