# # Collective Knowledge (platform - Neural Network accelerator) # # See CK LICENSE.txt for licensing details # See CK COPYRIGHT.txt for copyright details # # Developer: Grigori Fursin, Grigori.Fursin@cTuning.org, http://fursin.net # cfg={} # Will be updated by CK (meta description of this module) work={} # Will be updated by CK (temporal data) ck=None # Will be updated by CK (initialized CK kernel) # Local settings ############################################################################## # Initialize module def init(i): """ Input: {} Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ return {'return':0} ############################################################################## # Detect Neural Network Accelerator def detect(i): """ Input: { (target) - if specified, use info from 'machine' module (host_os) - host OS (detect, if omitted) (os) or (target_os) - OS module to check (if omitted, analyze host) (device_id) - device id if remote (such as adb) (skip_device_init) - if 'yes', do not initialize device (print_device_info) - if 'yes', print extra device info (skip_info_collection) - if 'yes', do not collect info (particularly for remote) (skip_print_os_info) - if 'yes', do not print OS info (exchange) - if 'yes', exchange info with some repo (by default, remote-ck) (share) - the same as 'exchange' (exchange_repo) - which repo to record/update info (remote-ck by default) (exchange_subrepo) - if remote, remote repo UOA (exchange_locally) - if 'yes', exchange locally (extra_info) - extra info about author, etc (see add from CK kernel) } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 features = { nn - Neural Network Accelerator features (properties), unified nn_misc - assorted Neural Network Accelerator features (properties), platform dependent } } """ import os o=i.get('out','') oo='' if o=='con': oo=o # Check if target if i.get('target','')!='': r=ck.access({'action':'init', 'module_uoa':cfg['module_deps']['machine'], 'input':i}) if r['return']>0: return r # Various params hos=i.get('host_os','') tos=i.get('target_os','') if tos=='': tos=i.get('os','') tdid=i.get('device_id','') sic=i.get('skip_info_collection','') sdi=i.get('skip_device_init','') pdv=i.get('print_device_info','') ex=i.get('exchange','') if ex=='': ex=i.get('share','') einf=i.get('extra_info','') if einf=='': einf={} # Get OS info import copy ii=copy.deepcopy(i) ii['out']=oo if i.get('skip_print_os_info','')=='yes': ii['out']='' ii['action']='detect' ii['module_uoa']=cfg['module_deps']['platform.cpu'] rr=ck.access(ii) # DO NOT USE rr further - will be reused as return ! if rr['return']>0: return rr hos=rr['host_os_uid'] hosx=rr['host_os_uoa'] hosd=rr['host_os_dict'] tos=rr['os_uid'] tosx=rr['os_uoa'] tosd=rr['os_dict'] tbits=tosd.get('bits','') tdid=rr['device_id'] # Some params ro=tosd.get('redirect_stdout','') remote=tosd.get('remote','') win=tosd.get('windows_base','') stdirs=tosd.get('dir_sep','') dv='' if tdid!='': dv=' -s '+tdid return {'return':1, 'error':'detection is not yet supported'} ############################################################################## # set frequency def set_freq(i): """ Input: { (host_os) - host OS (detect, if omitted) (os) or (target_os) - OS module to check (if omitted, analyze host) (device_id) - device id if remote (such as adb) (value) = "max" (default) "min" int value } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ import os o=i.get('out','') oo='' if o=='con': oo=o v=i.get('value','') if v=='': v='max' # Various params hos=i.get('host_os','') tos=i.get('target_os','') if tos=='': tos=i.get('os','') tdid=i.get('device_id','') # Get OS info import copy ii=copy.deepcopy(i) ii['out']='' ii['action']='detect' ii['module_uoa']=cfg['module_deps']['platform.os'] ii['skip_info_collection']='yes' ii['skip_device_init']='yes' rr=ck.access(ii) if rr['return']>0: return rr hos=rr['host_os_uid'] hosx=rr['host_os_uoa'] hosd=rr['host_os_dict'] tos=rr['os_uid'] tosx=rr['os_uoa'] tosd=rr['os_dict'] tbits=tosd.get('bits','') tdid=rr['device_id'] dir_sep=tosd.get('dir_sep','') remote=tosd.get('remote','') return {'return':1, 'error':'under construction ...'} ############################################################################## # viewing entries as html def show(i): """ Input: { data_uoa } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 html - generated HTML } """ h='
\n' h+=' #\n' h+=' | \n' h+='\n' h+=' Vendor\n' h+=' | \n' h+='\n' h+=' Name\n' h+=' | \n' h+='\n' h+=' Notes\n' h+=' | \n' h+='\n' h+=' CK UID\n' h+=' | \n' h+='
\n' h+=' '+str(num)+'\n' h+=' | \n' h+='\n' h+=' '+vendor+'\n' h+=' | \n' h+='\n' h+=' '+name+'\n' h+=' | \n' h+='\n' h+=' '+notes+'\n' h+=' | \n' h+='\n' h+=' '+duid+'\n' h+=' | \n' h+='