@@ -93,6 +93,10 @@ def __init__(self, name):
93
93
self .steps = set ()
94
94
self .children = set ()
95
95
96
+ ###############################################################################
97
+ def ignored (ns , a = None ):
98
+ return ns in ignore and ((a != None and a in ignore [ns ]) or (a == None and not ignore [ns ]))
99
+
96
100
97
101
###############################################################################
98
102
###############################################################################
@@ -150,7 +154,7 @@ def read(self):
150
154
for filename in filenames :
151
155
if filename .endswith ('.h' ) and not 'neural_networks' in dirpath and not any (filename .endswith (x ) for x in cython_interface .ignore_files ):
152
156
fname = jp (dirpath ,filename )
153
- print ('reading ' + fname )
157
+ # print('reading ' + fname)
154
158
with open (fname , "r" ) as header :
155
159
parsed_data = parse_header (header , cython_interface .ignores )
156
160
@@ -234,7 +238,7 @@ def get_all_attrs(self, ns, cls, attr, ons=None):
234
238
tmp = getattr (self .namespace_dict [ns ].classes [cls ], attr )
235
239
for a in tmp :
236
240
n = a if '::' in a else ns + '::' + a
237
- if ons not in ignore or n not in ignore [ ons ] :
241
+ if not ignored ( ons , n ) :
238
242
pmembers [n ] = tmp [a ]
239
243
for parent in self .namespace_dict [ns ].classes [cls ].parent :
240
244
parentclass = cls
@@ -247,7 +251,7 @@ def get_all_attrs(self, ns, cls, attr, ons=None):
247
251
pms = self .get_all_attrs (pns , parentclass , attr , ons )
248
252
for x in pms :
249
253
# ignore duplicates from parents
250
- if (ons not in ignore or x not in ignore [ ons ] ) and not any (x == y for y in pmembers ):
254
+ if not ignored (ons , x ) and not any (x == y for y in pmembers ):
251
255
pmembers [x ] = pms [x ]
252
256
return pmembers
253
257
@@ -390,12 +394,12 @@ def get_expand_attrs(self, ns, cls, attr):
390
394
assert ins in self .namespace_dict
391
395
assert inp in self .namespace_dict [ins ].enums
392
396
hlt = self .to_hltype (ns , attrs [i ])
393
- if ns in ignore and '::' .join ([ins , inp ]) in ignore [ ns ] :
397
+ if ignored ( ns , '::' .join ([ins , inp ])) :
394
398
continue
395
399
if hlt :
396
400
if hlt [1 ] in ['stdtype' , 'enum' , 'class' ]:
397
401
for e in self .namespace_dict [ins ].enums [inp ]:
398
- if not any (e in x for x in explist ) and (ins not in ignore or e not in ignore [ ins ] ):
402
+ if not any (e in x for x in explist ) and not ignored (ins , e ):
399
403
explist .append ((ins , e , hlt [0 ]))
400
404
else :
401
405
print ("// Warning: ignoring " + ns + " " + str (hlt ))
@@ -460,7 +464,7 @@ def prepare_modelmaps(self, ns, mname='Model'):
460
464
###############################################################################
461
465
def expand_typedefs (self , ns ):
462
466
"""
463
- We expand all typedefs in classes/namespaces wihtout recursing
467
+ We expand all typedefs in classes/namespaces without recursing
464
468
to outer scopes or namespaces.
465
469
"""
466
470
def expand_td (typedefs ):
@@ -604,7 +608,7 @@ def prepare_hlwrapper(self, ns, mode, func):
604
608
jparams ['params_opt' ] = OrderedDict ()
605
609
for p in parms :
606
610
pns , tmp = splitns (p )
607
- if not tmp .startswith ('_' ) and (pns not in ignore or tmp not in ignore [ pns ] ):
611
+ if not tmp .startswith ('_' ) and not ignored (pns , tmp ):
608
612
hlt = self .to_hltype (pns , parms [p ])
609
613
if hlt and hlt [1 ] in ['stdtype' , 'enum' , 'class' ]:
610
614
(hlt , hlt_type , hlt_ns ) = hlt
@@ -647,7 +651,7 @@ def prepare_hlwrapper(self, ns, mode, func):
647
651
reqi = 0
648
652
for ins , iname , itype in expinputs [0 ]:
649
653
tmpi = iname
650
- if tmpi and (ns not in ignore or tmpi not in ignore [ ns ] ):
654
+ if tmpi and not ignored (ns , tmpi ):
651
655
if ns in defaults and tmpi in defaults [ns ]:
652
656
i = len (tmp_iargs_decl )
653
657
dflt = ' = ' + defaults [ns ][tmpi ]
@@ -717,28 +721,23 @@ def hlapi(self, algo_patterns):
717
721
algos = [x for x in self .namespace_dict if any (y in x for y in algo_patterns )] if algo_patterns else self .namespace_dict
718
722
algos = [x for x in algos if not any (y in x for y in ['quality_metric' , 'transform' ])]
719
723
720
- # we first extract and prepare the data (input, parameters, results, template spec)
721
- # some algo need to combine several configs, like kmeans needs kmeans::init
724
+ # First expand typedefs
722
725
for ns in algos + ['algorithms::classifier' , 'algorithms::linear_model' ,]:
723
- # expand typedefs
724
726
self .expand_typedefs (ns )
725
- if not ns .startswith ('algorithms::neural_networks' ):
726
- if not any (ns .endswith (x ) for x in ['objective_function' , 'iterative_solver' ]):
727
- nn = ns .split ('::' )
728
- if nn [0 ] == 'daal' :
729
- if nn [1 ] == 'algorithms' :
730
- func = '_' .join (nn [2 :])
731
- else :
732
- func = '_' .join (nn [1 :])
733
- elif nn [0 ] == 'algorithms' :
734
- func = '_' .join (nn [1 :])
727
+ # Next, extract and prepare the data (input, parameters, results, template spec)
728
+ for ns in algos + ['algorithms::classifier' , 'algorithms::linear_model' ,]:
729
+ if not ignored (ns ):
730
+ nn = ns .split ('::' )
731
+ if nn [0 ] == 'daal' :
732
+ if nn [1 ] == 'algorithms' :
733
+ func = '_' .join (nn [2 :])
735
734
else :
736
- func = '_' .join (nn )
737
- #if any(ns.endswith(x) for x in ['prediction', 'training', 'init', 'transform']) :
738
- # func = '_'.join(tmp [1:])
739
- # else:
740
- # func = tmp[-1]
741
- algoconfig .update (self .prepare_hlwrapper (ns , 'Batch' , func ))
735
+ func = '_' .join (nn [ 1 :] )
736
+ elif nn [ 0 ] == 'algorithms' :
737
+ func = '_' .join (nn [1 :])
738
+ else :
739
+ func = '_' . join ( nn )
740
+ algoconfig .update (self .prepare_hlwrapper (ns , 'Batch' , func ))
742
741
743
742
# and now we can finally generate the code
744
743
wg = wrapper_gen (algoconfig , {cpp2hl (i ): ifaces [i ] for i in ifaces })
0 commit comments