Skip to content

Commit

Permalink
create primitive factory only when the factory has been registered (#…
Browse files Browse the repository at this point in the history
…10029)

搬运: Oneflow-Inc/oneflow-mlu#9

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
BBuf and mergify[bot] authored Mar 25, 2023
1 parent cf7d5d3 commit 0571bff
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions oneflow/core/ep/include/primitive/primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Factory {
template<typename FactoryType, typename... Args>
static std::unique_ptr<typename FactoryType::PrimitiveType> NewPrimitive(DeviceType device_type,
Args&&... args) {
if (!IsClassRegistered<DeviceType, FactoryType>(device_type)) { return nullptr; }
std::unique_ptr<FactoryType> factory = NewObjUniquePtr<DeviceType, FactoryType>(device_type);
if (!factory) { return nullptr; }
return factory->New(std::forward<Args>(args)...);
Expand Down

0 comments on commit 0571bff

Please sign in to comment.