MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / OpKernelRegistrar

Class OpKernelRegistrar

tensorflow/core/framework/op_kernel.h:1566–1604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1564};
1565
1566class OpKernelRegistrar {
1567 public:
1568 // Registers the given kernel factory with TensorFlow. TF will call the
1569 // factory Create() method when it determines that a kernel matching the given
1570 // KernelDef is required.
1571 OpKernelRegistrar(const KernelDef* kernel_def, StringPiece kernel_class_name,
1572 std::unique_ptr<OpKernelFactory> factory) {
1573 // Perform the check in the header to allow compile-time optimization
1574 // to a no-op, allowing the linker to remove the kernel symbols.
1575 if (kernel_def != nullptr) {
1576 InitInternal(kernel_def, kernel_class_name, std::move(factory));
1577 }
1578 }
1579
1580 // Registers the given factory function with TensorFlow. This is equivalent
1581 // to registering a factory whose Create function invokes `create_fn`.
1582 OpKernelRegistrar(const KernelDef* kernel_def, StringPiece kernel_class_name,
1583 OpKernel* (*create_fn)(OpKernelConstruction*)) {
1584 // Perform the check in the header to allow compile-time optimization
1585 // to a no-op, allowing the linker to remove the kernel symbols.
1586 if (kernel_def != nullptr) {
1587 InitInternal(kernel_def, kernel_class_name,
1588 absl::make_unique<PtrOpKernelFactory>(create_fn));
1589 }
1590 }
1591
1592 private:
1593 struct PtrOpKernelFactory : public OpKernelFactory {
1594 explicit PtrOpKernelFactory(OpKernel* (*create_func)(OpKernelConstruction*))
1595 : create_func_(create_func) {}
1596
1597 OpKernel* Create(OpKernelConstruction* context) override;
1598
1599 OpKernel* (*create_func_)(OpKernelConstruction*);
1600 };
1601
1602 void InitInternal(const KernelDef* kernel_def, StringPiece kernel_class_name,
1603 std::unique_ptr<OpKernelFactory> factory);
1604};
1605
1606} // namespace kernel_factory
1607

Callers 1

TF_RegisterKernelBuilderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected