Packages
extorch_vision
0.1.0
TorchVision ops for ExTorch — NMS, ROI Align, deformable convolution, and image I/O on the BEAM. Builds libtorchvision from source, no C++ code in this package.
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/torchvision_build.ex
defmodule Mix.Tasks.Torchvision.Build do
@moduledoc """
Build libtorchvision.so from source.
Downloads the torchvision source code matching your libtorch version
and builds it via CMake. The resulting library is placed in priv/
and loaded at runtime by `ExTorch.Vision.setup!/0`.
## Requirements
* cmake (>= 3.18)
* A C++17 compiler (gcc >= 7 or clang >= 5)
* libtorch (already installed by ExTorch)
* CUDA toolkit (optional, for GPU support)
## Usage
mix torchvision.build
## Options
* `--force` - Rebuild even if libtorchvision.so already exists
"""
use Mix.Task
@shortdoc "Build libtorchvision.so from source"
@impl Mix.Task
def run(args) do
{opts, _, _} = OptionParser.parse(args, switches: [force: :boolean])
if opts[:force] do
lib = ExTorch.Vision.Build.lib_path()
File.rm(lib)
IO.puts("Removed existing #{lib}")
end
# Ensure extorch is compiled first (downloads libtorch if needed)
Mix.Task.run("compile", [])
ExTorch.Vision.Build.ensure_built!()
IO.puts("Done.")
end
end