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.yamlaten/src/ATen/native/UnaryOps.haten/src/ATen/native/UnaryOps.cppaten/src/ATen/native/cpu/UnaryOpsKernel.cppaten/src/ATen/cpu/vml.haten/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.haten/src/ATen/core/TensorBody.haten/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.