ExTorch.Native.BindingDeclaration (extorch v0.1.0-pre0)
Conveniences for declaring native calls to a library in Rustler.
This module can be use
-d into a module in order to declare
a set of native functions:
defmodule NativeCalls do
use ExTorch.Native.BindingDeclaration
defbindings(:doc_section) do
@doc """
Get the size of a tensor.
## Arguments
- `tensor`: Input tensor
"""
@spec size(ExTorch.Tensor.t()) :: tuple()
defbinding(size(tensor))
end
end
binding-behaviour
Binding behaviour
Internally, ExTorch.Native.BindingDeclaration
implements the following
macros:
__using__/0
: Enables the module to be used on a module that usesRustler
in order to define the stub definitions for the native functions to call.defmodule NativeExtension do use NativeCalls use Rustler, otp_app: :app_name, crate: "crate_name" end