Tenncor
Classes | Functions | Variables
pyapis Namespace Reference

Classes

class  PyAPIsPlugin
 

Functions

def _sub_pybind (stmt, source)
 
def _strip_template_prefix (template)
 
def _mangle_func (idx, api, namespace)
 
def _handle_pybind (pybind_type)
 
def _handle_pybind_type (pybind_type)
 
def _handle_name_mangling (pybind_type, apis, namespace)
 
def _parse_header_args (arg)
 
def _parse_description (arg)
 
def _parse_pyargs (arg)
 
def _def_op (t2labels, api)
 
def _handle_defs (pybind_type, apis, module_name, first_module)
 

Variables

string _pybindt = 'PybindT'
 
string _header_template
 
string _source_template
 
string _func_fmt
 
dictionary _py_op
 
dictionary __py_op_rev
 
string _def_op_tmpl = '{label}.def("{pyop}", []({params}){{ return {operator}; }}, py::is_operator());'
 
string _plugin_id = 'PYBINDER'
 

Function Documentation

◆ _def_op()

def pyapis._def_op (   t2labels,
  api 
)
private

◆ _handle_defs()

def pyapis._handle_defs (   pybind_type,
  apis,
  module_name,
  first_module 
)
private

◆ _handle_name_mangling()

def pyapis._handle_name_mangling (   pybind_type,
  apis,
  namespace 
)
private

◆ _handle_pybind()

def pyapis._handle_pybind (   pybind_type)
private

◆ _handle_pybind_type()

def pyapis._handle_pybind_type (   pybind_type)
private

◆ _mangle_func()

def pyapis._mangle_func (   idx,
  api,
  namespace 
)
private

◆ _parse_description()

def pyapis._parse_description (   arg)
private

◆ _parse_header_args()

def pyapis._parse_header_args (   arg)
private

◆ _parse_pyargs()

def pyapis._parse_pyargs (   arg)
private

◆ _strip_template_prefix()

def pyapis._strip_template_prefix (   template)
private

◆ _sub_pybind()

def pyapis._sub_pybind (   stmt,
  source 
)
private

Variable Documentation

◆ __py_op_rev

dictionary pyapis.__py_op_rev
private
Initial value:
1 = {
2  '+': '__radd__',
3  '*': '__rmul__',
4  '-': '__rsub__',
5  '/': '__rtruediv__',
6 }

◆ _def_op_tmpl

string pyapis._def_op_tmpl = '{label}.def("{pyop}", []({params}){{ return {operator}; }}, py::is_operator());'
private

◆ _func_fmt

string pyapis._func_fmt
private
Initial value:
1 = '''
2 {outtype} {funcname}_{idx} ({param_decl})
3 {{
4  return {namespace}::{funcname}({args});
5 }}
6 '''

◆ _header_template

string pyapis._header_template
private
Initial value:
1 = '''
2 // type to replace template arguments in pybind
3 using {pybind} = {pybind_type};
4 //>>> ^ pybind, pybind_type
5 
6 using NodeptrT = eteq::NodeptrT<{pybind}>;
7 '''

◆ _plugin_id

string pyapis._plugin_id = 'PYBINDER'
private

◆ _py_op

dictionary pyapis._py_op
private
Initial value:
1 = {
2  ('-', 1): '__neg__',
3  ('+', 2): '__add__',
4  ('*', 2): '__mul__',
5  ('-', 2): '__sub__',
6  ('/', 2): '__truediv__',
7  ('==', 2): '__eq__',
8  ('!=', 2): '__ne__',
9  ('<', 2): '__lt__',
10  ('>', 2): '__gt__',
11 }

◆ _pybindt

string pyapis._pybindt = 'PybindT'
private

◆ _source_template

string pyapis._source_template
private
Initial value:
1 = '''
2 namespace py = pybind11;
3 
4 namespace pyegen
5 {{
6 
7 //>>> name_mangling
8 {name_mangling}
9 
10 }}
11 
12 //>>> modname
13 PYBIND11_MODULE({modname}, m_{modname})
14 {{
15  m_{modname}.doc() = "pybind for {modname} api";
16 
17  //>>> modname
18  py::class_<teq::iTensor,teq::TensptrT> tensor(m_{modname}, "Tensor");
19 
20  //>>> defs
21  {defs}
22 }}
23 '''