Ошибка при вычислении пользовательского слоя CoreML "----" на графическом процессоре? - PullRequest
0 голосов
/ 21 февраля 2019

Я получаю эту ошибку без каких-либо других подробностей.

Это металлический код

#include <metal_stdlib>
using namespace metal;

kernel void copy(texture2d_array<half, access::read>  in_texture [[texture(0)]] ,
                 texture2d_array<half, access::write> out_texture [[texture(1)]],
                 ushort3 gid [[thread_position_in_grid]])
{
    if (gid.x >= out_texture.get_width() || gid.y >= out_texture.get_height()) {
        return;
    }

    const float4 x = float4(in_texture.read(gid.xy, gid.z));
    out_texture.write(half4(x), gid.xy, gid.z);
}

Это реализация буфера компьютера.

-(BOOL)encodeToCommandBuffer:(id<MTLCommandBuffer>)commandBuffer inputs:(NSArray<id<MTLTexture>> *)inputs outputs:(NSArray<id<MTLTexture>> *)outputs error:(NSError *__autoreleasing  _Nullable *)error
{
    auto encoder = [commandBuffer computeCommandEncoder];
    [encoder setTexture: input  atIndex: 0];
    [encoder setTexture: output atIndex: 1];
    [encoder setComputePipelineState:_pipeline];

    // Set the compute kernel's threadgroup size of 16x16
    MTLSize thread_group_size = MTLSizeMake(16, 16, 1);

    MTLSize thread_group_count = MTLSizeMake(0, 0, 1);

    // Calculate the number of rows and columns of threadgroups given the width of the input image
    // Ensure that you cover the entire image (or more) so you process every pixel
    thread_group_count.width   = (input.width  + thread_group_size.width -  1) / thread_group_size.width;
    thread_group_count.height  = (input.height + thread_group_size.height - 1)  / thread_group_size.height;

    [encoder dispatchThreadgroups:thread_group_count threadsPerThreadgroup:thread_group_size];
    [encoder endEncoding];
}


На основе: https://machinethink.net/blog/coreml-custom-layers/

Чтоя могу использовать, чтобы определить ошибку?Я попытался использовать пустой encodeToCommandBuffer, и я все еще получаю ту же ошибку.

...