Open3D (C++ API)
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Data Structures | Functions | Variables
generate_torch_ops_wrapper Namespace Reference

Data Structures

class  Argument
 

Functions

def parse_schema_from_docstring (docstring)
 
def get_tensorflow_docstring_from_file (path)
 
def find_op_reg_file (ops_dir, op_name)
 
def main ()
 

Variables

string INDENT_SPACES = ' '
 
string FN_TEMPLATE_STR
 
string FN_RETURN_NAMEDTUPLE_TEMPLATE_STR
 
string NAMEDTUPLE_TEMPLATE_STR = "{name} = _namedtuple( '{name}', '{fields}')\n"
 
 Schema = namedtuple('Schema', ['name', 'arguments', 'returns'])
 

Detailed Description

This script inspects the open3d_torch_ops library and generates function wrappers

Function Documentation

◆ find_op_reg_file()

def generate_torch_ops_wrapper.find_op_reg_file (   ops_dir,
  op_name 
)
Tries to find the corresponding tensorflow file for the op_name

◆ get_tensorflow_docstring_from_file()

def generate_torch_ops_wrapper.get_tensorflow_docstring_from_file (   path)
Extracts the docstring from a tensorflow register op file

◆ main()

def generate_torch_ops_wrapper.main ( )

◆ parse_schema_from_docstring()

def generate_torch_ops_wrapper.parse_schema_from_docstring (   docstring)
Parses the schema from the definition in the docstring of the function.

At the moment we only allow tuples and a single Tensor as return value.
All input arguments must have a name.
E.g. the following are schemas for which we can generate wrappers

open3d::my_function(int a, Tensor b, Tensor c) -> (Tensor d, Tensor e)
open3d::my_function(int a, Tensor b, Tensor c) -> Tensor d
open3d::my_function(int a, Tensor b, str c='bla') -> Tensor d

Variable Documentation

◆ FN_RETURN_NAMEDTUPLE_TEMPLATE_STR

string generate_torch_ops_wrapper.FN_RETURN_NAMEDTUPLE_TEMPLATE_STR
Initial value:
1 = '''
2 def {fn_name}({fn_args}):
3 {docstring}
4  return return_types.{fn_name}(*_torch.ops.open3d.{fn_name}({args_fwd}))
5 
6 '''

◆ FN_TEMPLATE_STR

string generate_torch_ops_wrapper.FN_TEMPLATE_STR
Initial value:
1 = '''
2 def {fn_name}({fn_args}):
3 {docstring}
4  return _torch.ops.open3d.{fn_name}({args_fwd})
5 
6 '''

◆ INDENT_SPACES

string generate_torch_ops_wrapper.INDENT_SPACES = ' '

◆ NAMEDTUPLE_TEMPLATE_STR

string generate_torch_ops_wrapper.NAMEDTUPLE_TEMPLATE_STR = "{name} = _namedtuple( '{name}', '{fields}')\n"

◆ Schema

generate_torch_ops_wrapper.Schema = namedtuple('Schema', ['name', 'arguments', 'returns'])