相关疑难解决方法(0)

newComputePipelineStateWithFunction失败

我试图让一个神经网络在金属上运行.基本思想是数据重复.每个gpu线程为随机数据点运行一个网络版本.

我写过其他着色器工作正常.

我还在c ++命令行应用程序中尝试了我的代码.没有错误.也没有编译错误.

我使用apple文档转换为metal c ++,因为不支持c ++ 11中的所有内容.

它在加载内核函数后以及在尝试分配newComputePipelineStateWithFunction给金属设备时崩溃.这意味着在编译时未捕获的代码存在问题.

MCVE:

kernel void net(const device float *inputsVector [[ buffer(0) ]], // layout of net *
                uint id [[ thread_position_in_grid ]]) {

    uint floatSize = sizeof(tempFloat);
    uint inputsVectorSize = sizeof(inputsVector) / floatSize;

    float newArray[inputsVectorSize];


    float test = inputsVector[id];

    newArray[id] = test;

}
Run Code Online (Sandbox Code Playgroud)

更新

它与动态数组有关.

由于它无法创建管道状态并且不会崩溃运行实际着色器,因此它必须是编码问题.不是输入问题.

将动态数组中的值分配给缓冲区会使其失败.

c++ metal

11
推荐指数
1
解决办法
614
查看次数

标签 统计

c++ ×1

metal ×1