Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

neilisaac / torch   python

Repository URL to install this package:

Version: 1.8.0 

/ include / torch / csrc / jit / python / module_python.h

#pragma once
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <torch/csrc/jit/api/module.h>

namespace py = pybind11;

namespace torch {
namespace jit {

inline c10::optional<Module> as_module(const py::object& obj) {
  if (py::isinstance(
          obj, py::module::import("torch.jit").attr("ScriptModule"))) {
    return py::cast<Module>(obj.attr("_c"));
  }
  return c10::nullopt;
}

} // namespace jit
} // namespace torch