Custom layer with multiple outputs

I added a custom layer to the end of a neural network that produces two outputs with the same shape [512].

However, when I try to load the model, I get a EXC_BAD_ACCESS with a huge stacktrace (see below). It looks like an endless recursion.


When I rewrite the spec and the layer to produce only one output with shape [512, 1, 2] it works, but I'm running into alignment issues later.


Is this a bug in Core ML or am I doeing something wrong?


#0 __memcpy_chk ()
#1 io_connect_method ()
#2 IOConnectCallMethod ()
#3 IOAccelResourceCreate ()
#4 -[MTLIOAccelResource initWithDevice:options:args:argsSize:] ()
#5 -[MTLIOAccelHeap initWithDevice:size:options:args:argsSize:] ()
#6 ___lldb_unnamed_symbol1064$$AGXMetalA11 ()
#7 -[MTLDebugDevice newHeapWithDescriptor:] ()
#8 Espresso::MPSEngine::blob_container::resize(int, int, int, int, int, std::__1::shared_ptr<Espresso::abstract_blob_container_options>) ()
#9 Espresso::shape_network(Espresso::net*, Espresso::network_shape const&) ()
#10 Espresso::shape_network(Espresso::net*, Espresso::network_shape const&) ()
#11 Espresso::shape_network(Espresso::net*, Espresso::network_shape const&) ()
...
#1571 Espresso::shape_network(Espresso::net*, Espresso::network_shape const&) ()
#1572 Espresso::shape_network(Espresso::net*, Espresso::network_shape const&) ()
#1573 Espresso::shape_network(Espresso::net*, Espresso::network_shape const&) ()
#1574 Espresso::shape_network(std::__1::shared_ptr<Espresso::net>, std::__1::basic_istream<char, std::__1::char_traits<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) ()
#1575 Espresso::load_network(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::shared_ptr<Espresso::abstract_context> const&, Espresso::compute_path) ()
#1576 EspressoLight::espresso_plan::add_network(char const*, espresso_storage_type_t) ()
#1577 espresso_plan_add_network ()
#1578 -[MLNeuralNetworkEngine _setupContextAndPlanWithForceCPU:error:] ()
#1579 -[MLNeuralNetworkEngine initWithSpec:classScoreVectorName:classLabels:forceCPU:error:] ()
#1580 -[MLNeuralNetworkEngine initWithSpec:classScoreVectorName:classLabels:error:] ()
#1581 +[MLNeuralNetworkEngine loadModelFromCompiledArchive:modelVersionInfo:compilerVersionInfo:error:] ()
#1582 +[MLLoader loadModelFromArchive:error:] ()
#1583 +[MLLoader loadModelFromAssetAtURL:error:] ()
#1584 -[MLModelAsset load:] ()
#1585 -[MLModelAsset modelWithError:] ()
#1586 +[MLModel modelWithContentsOfURL:error:] ()
#1587 @nonobjc MLModel.__allocating_init(contentsOf:) ()
#1588 MyModel.init(contentsOf:)
#1589 MyModel.init()

Replies

This is a bug in CoreML 😟


Please create a bug report (https://bugreport.apple.com/) with this stack trace and any additional model / custom layer details you can share.