forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
Adding new unary operators to pytorch
Pearu Peterson edited this page Sep 18, 2019
·
1 revision
To implement a new unary operation to pytrorch, one needs to change the following files (for required changes, use some existing unary operation (say, exp
) as a template and do copy-paste-rename):
aten/src/ATen/native/native_functions.yaml
aten/src/ATen/native/UnaryOps.h
aten/src/ATen/native/UnaryOps.cpp
aten/src/ATen/native/cpu/UnaryOpsKernel.cpp
aten/src/ATen/cpu/vml.h
aten/src/ATen/cpu/vec256/vec256_{base, double, float, ...}.h
The following files will be re-generated (requires using environment variable GEN_TO_SOURCE=1
):
aten/src/ATen/core/TensorMethods.h
aten/src/ATen/core/TensorBody.h
aten/src/ATen/core/OpsAlreadyMovedToC10.cpp
The may exist several libraries that implement the same math function: C++ std, sleef, mkl, vml, etc. Enable the one that is fastest, for instance, for some functions sleef
implementation is more performant that of mkl
while pytorch uses mkl
by default when available.