Skip to content

Commit 0a2bf93

Browse files
authored
-Gate lazy registration logic behind compile time macros
Differential Revision: D79273509 Pull Request resolved: #13134
1 parent 9574270 commit 0a2bf93

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

backends/apple/coreml/runtime/delegate/coreml_backend_delegate.mm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@
8888
ET_LOG(Error, "%s: DataType=%d is not supported", ETCoreMLStrings.delegateIdentifier.UTF8String, (int)tensor.scalar_type());
8989
return std::nullopt;
9090
}
91-
91+
9292
std::vector<ssize_t> strides(tensor.strides().begin(), tensor.strides().end());
9393
std::vector<size_t> shape(tensor.sizes().begin(), tensor.sizes().end());
94-
94+
9595
// If tensor is rank 0, wrap in rank 1
9696
// See https://github.com/apple/coremltools/blob/8.2/coremltools/converters/mil/frontend/torch/exir_utils.py#L73
9797
if (shape.size() == 0) {
9898
shape.push_back(1);
9999
strides.push_back(1);
100100
}
101-
101+
102102
MultiArray::MemoryLayout layout(dataType.value(), std::move(shape), std::move(strides));
103103
switch (argType) {
104104
case ArgType::Input: {
@@ -281,9 +281,11 @@ ModelLoggingOptions get_logging_options(BackendExecutionContext& context) {
281281
}
282282

283283
namespace {
284-
auto cls = CoreMLBackendDelegate();
285-
Backend backend{ETCoreMLStrings.delegateIdentifier.UTF8String, &cls};
286-
static auto success_with_compiler = register_backend(backend);
284+
#ifndef LAZY_LOAD_IOS_PYTORCH_INITIALIZER
285+
auto cls = CoreMLBackendDelegate();
286+
Backend backend{ETCoreMLStrings.delegateIdentifier.UTF8String, &cls};
287+
static auto success_with_compiler = register_backend(backend);
288+
#endif
287289
}
288290

289291
} // namespace coreml

0 commit comments

Comments
 (0)