def c_support_code(self): ccode = mkl_helper.header_text() ccode += """ #define L_PASS (1) #define __DEBUG__ 0 """ return ccode
def c_support_code(self): ccode = header_text() ccode += """ #if PY_MAJOR_VERSION >= 3 #define PyInt_FromLong PyLong_FromLong #endif """ return ccode
def c_support_code(self): ccode = header_text() ccode += """ #define DIMENSION (4) #define CHECK_ERR(f, err) \\ do { \\ (err) = (f); \\ if ((err) != E_SUCCESS) { \\ printf("Error in file [%s:%d], err code (%d)", \\ __FILE__, __LINE__, err); \\ exit(1); \\ } \\ } while(0) """ return ccode
def c_support_code(self): return mkl_helper.header_text()
def mkl_available(): if config.device != "cpu": mkl_available.avail = False mkl_available.msg = "MKL is disabled since device is not CPU. " \ "Set the device to 'CPU' if you want to use MKL." return mkl_available.avail if config.mkl.lib != "mkl": raise NotImplementedError("MKL lib only supports 'mkl', got %s." % config.mkl.lib) if config.mkl.nn.enabled == "False": mkl_available.avail = False mkl_available.msg = "MKL is disabled by the 'mkl.nn.enabled' setting." return mkl_available.avail elif mkl_available.avail is not True: preambule = """ #include <stdio.h> """ preambule += textwrap.dedent(header_text()) body = textwrap.dedent( """ dnnError_t err; dnnLayout_t usr_layout = NULL; size_t size[1] = {256}; size_t stride[1] = {1}; if ((err = dnnLayoutCreate_F32(&usr_layout, 1, size, stride)) != E_SUCCESS) { fprintf(stderr, "Failed to create user layout with mkl: %s", err); return (-1); } """) if 'mklml_intel' in config.blas.ldflags: params = ['-l', 'mklml_intel'] else: params = ['-l', 'mkl_rt'] comp, out, err = Compiler._try_flags( flag_list=params, preambule=preambule, body=body, try_run=False, output=True, compiler=theano.config.cxx, comp_args=False) mkl_available.avail = comp if mkl_available.avail is False: mkl_available.msg = ( "Can not compile with MKL. We got this error: " + str(err)) else: # If we can compile, check that we can import and run. v = theano.function([], MKLVersion()(), theano.Mode(optimizer=None), profile=False)() if not isinstance(v, integer_types): mkl_available.avail = False mkl_available.msg = ("Got incorrect mkl version format") raise RuntimeError(mkl_available.msg) if v == -1 or v < 20160802: mkl_available.avail = False mkl_available.msg = "Version(%d) is too old, please use the version of %d or newer one." % (v, int(20160802)) raise RuntimeError(mkl_available.msg) else: mkl_available.avail = comp if config.mkl.nn.enabled == "True": if not mkl_available.avail: raise RuntimeError( "You enabled MKL, but we aren't able to use it, %s" % mkl_available.msg) return mkl_available.avail
def mkl_available(): if config.device != "cpu": mkl_available.avail = False mkl_available.msg = "MKL is disabled since device is not CPU. " \ "Set the device to 'CPU' if you want to use MKL." return mkl_available.avail if config.mkl.lib != "mkl": raise NotImplementedError("MKL lib only supports 'mkl', got %s." % config.mkl.lib) if config.mkl.nn.enabled == "False": mkl_available.avail = False mkl_available.msg = "MKL is disabled by the 'mkl.nn.enabled' setting." return mkl_available.avail elif mkl_available.avail is not True: preambule = """ #include <stdio.h> """ preambule += textwrap.dedent(header_text()) body = textwrap.dedent(""" dnnError_t err; dnnLayout_t usr_layout = NULL; size_t size[1] = {256}; size_t stride[1] = {1}; if ((err = dnnLayoutCreate_F32(&usr_layout, 1, size, stride)) != E_SUCCESS) { fprintf(stderr, "Failed to create user layout with mkl: %s", err); return (-1); } """) if 'mklml_intel' in config.blas.ldflags: params = ['-l', 'mklml_intel'] else: params = ['-l', 'mkl_rt'] comp, out, err = Compiler._try_flags(flag_list=params, preambule=preambule, body=body, try_run=False, output=True, compiler=theano.config.cxx, comp_args=False) mkl_available.avail = comp if mkl_available.avail is False: mkl_available.msg = ( "Can not compile with MKL. We got this error: " + str(err)) else: # If we can compile, check that we can import and run. v = theano.function([], MKLVersion()(), theano.Mode(optimizer=None), profile=False)() if not isinstance(v, integer_types): mkl_available.avail = False mkl_available.msg = ("Got incorrect mkl version format") raise RuntimeError(mkl_available.msg) if v == -1 or v < 20160802: mkl_available.avail = False mkl_available.msg = "Version(%d) is too old, please use the version of %d or newer one." % ( v, int(20160802)) raise RuntimeError(mkl_available.msg) else: mkl_available.avail = comp if config.mkl.nn.enabled == "True": if not mkl_available.avail: raise RuntimeError( "You enabled MKL, but we aren't able to use it, %s" % mkl_available.msg) return mkl_available.avail