CppExtension

paddle.utils.cpp_extension. CppExtension ( sources, *args, **kwargs ) [source]

The interface is used to config source files of customized operators and complies Op Kernel only supporting CPU device. Please use CUDAExtension if you want to compile Op Kernel that supports both CPU and GPU devices.

It further encapsulates python built-in setuptools.Extension .The arguments and usage are same as the native interface, except for no need to explicitly specify name .

A simple example:

# setup.py

# Compiling customized operators supporting only CPU device
from paddle.utils.cpp_extension import CppExtension, setup

setup(
    name='custom_op',
    ext_modules=CppExtension(sources=['relu_op.cc'])
)

Note

It is mainly used in setup and the name of built shared library keeps same as name argument specified in setup interface.

Parameters
  • sources (list[str]) – Specify the C++/CUDA source files of customized operators.

  • *args (list[options], optional) – Specify other arguments same as setuptools.Extension .

  • **kwargs (dict[option], optional) – Specify other arguments same as setuptools.Extension .

Returns

An instance of setuptools.Extension

Return type

setuptools.Extension