theano/gof/op.py
def load_c_code(self, func_files):
        """
        Loads the c code to perform the Op
        """
        func_files = [self.get_path(f) for f in func_files]
        self.func_codes = []
        for func_file in func_files:
            # U (universal) will convert all new lines format to \n.
            with _open_u(func_file) as f:
                self.func_codes.append(f.read())

        # If both the old section markers and the new section markers are
        # present, raise an error because we don't know which ones to follow.
        old_markers_present = False
        new_markers_present = False
        for code in self.func_codes:
            if self.backward_re.search(code):
                old_markers_present = True
            if self.section_re.search(code):
                new_markers_present = True

        if old_markers_present and new_markers_present:
            raise ValueError('Both the new and the old syntax for '
                             'identifying code sections are present in the '
                             'provided C code. These two syntaxes should not '
                             'be used at the same time.')

        self.code_sections = dict()
        for i, code in enumerate(self.func_codes):
            if self.backward_re.search(code):
                # This is backward compat code that will go away in a while

                # Separate the code into the proper sections
                split = self.backward_re.split(code)
                n = 1
                while n < len(split):
                    if split[n] == 'APPLY':
                        self.code_sections['support_code_apply'] = split[n + 1]
                    elif split[n] == 'SUPPORT':
                        self.code_sections['support_code'] = split[n + 1]
                    n += 2
                continue

            elif self.section_re.search(code):

                # Check for code outside of the supported sections
                split = self.section_re.split(code)
                if split[0].strip() != '':
                    raise ValueError('Stray code before first #section '
                                     'statement (in file %s): %s' %
                                     (func_files[i], split[0]))

                # Separate the code into the proper sections
                n = 1
                while n < len(split):
                    if split[n] not in self.SECTIONS:
                        raise ValueError(
                            "Unknown section type (in file %s): %s" %
                            (func_files[i], split[n]))
                    if split[n] not in self.code_sections:
                        self.code_sections[split[n]] = ""
                    self.code_sections[split[n]] += split[n + 1]
                    n += 2

            else:
                raise ValueError("No valid section marker was found in file "
                                 "%s" % func_files[i])

        Loads the c code to perform the Op
        
Loads the c code to perform the Op
Loads the c code to perform the Op
def load_c_code(self, func_files):
        func_files = [self.get_path(f) for f in func_files]
        self.func_codes = []
        for func_file in func_files:
            with _open_u(func_file) as f:
                self.func_codes.append(f.read())
        old_markers_present = False
        new_markers_present = False
        for code in self.func_codes:
            if self.backward_re.search(code):
                old_markers_present = True
            if self.section_re.search(code):
                new_markers_present = True
        if old_markers_present and new_markers_present:
            raise ValueError('Both the new and the old syntax for '
                             'identifying code sections are present in the '
                             'provided C code. These two syntaxes should not '
                             'be used at the same time.')
        self.code_sections = dict()
        for i, code in enumerate(self.func_codes):
            if self.backward_re.search(code):
                split = self.backward_re.split(code)
                n = 1
                while n < len(split):
                    if split[n] == 'APPLY':
                        self.code_sections['support_code_apply'] = split[n + 1]
                    elif split[n] == 'SUPPORT':
                        self.code_sections['support_code'] = split[n + 1]
                    n += 2
                continue
            elif self.section_re.search(code):
                split = self.section_re.split(code)
                if split[0].strip() != '':
                    raise ValueError('Stray code before first #section '
                                     'statement (in file %s): %s' %
                                     (func_files[i], split[0]))
                n = 1
                while n < len(split):
                    if split[n] not in self.SECTIONS:
                        raise ValueError(
                            "Unknown section type (in file %s): %s" %
                            (func_files[i], split[n]))
                    if split[n] not in self.code_sections:
                        self.code_sections[split[n]] = ""
                    self.code_sections[split[n]] += split[n + 1]
                    n += 2
            else:
                raise ValueError("No valid section marker was found in file "
                                 "%s" % func_files[i])
def load_c_code ( self , func_files ) : func_files = [ self . get_path ( f ) for f in func_files ] self . func_codes = [ ] for func_file in func_files : with _open_u ( func_file ) as f : self . func_codes . append ( f . read ( ) ) old_markers_present = False new_markers_present = False for code in self . func_codes : if self . backward_re . search ( code ) : old_markers_present = True if self . section_re . search ( code ) : new_markers_present = True if old_markers_present and new_markers_present : raise ValueError ( 'Both the new and the old syntax for ' 'identifying code sections are present in the ' 'provided C code. These two syntaxes should not ' 'be used at the same time.' ) self . code_sections = dict ( ) for i , code in enumerate ( self . func_codes ) : if self . backward_re . search ( code ) : split = self . backward_re . split ( code ) n = 1 while n < len ( split ) : if split [ n ] == 'APPLY' : self . code_sections [ 'support_code_apply' ] = split [ n + 1 ] elif split [ n ] == 'SUPPORT' : self . code_sections [ 'support_code' ] = split [ n + 1 ] n += 2 continue elif self . section_re . search ( code ) : split = self . section_re . split ( code ) if split [ 0 ] . strip ( ) != '' : raise ValueError ( 'Stray code before first #section ' 'statement (in file %s): %s' % ( func_files [ i ] , split [ 0 ] ) ) n = 1 while n < len ( split ) : if split [ n ] not in self . SECTIONS : raise ValueError ( "Unknown section type (in file %s): %s" % ( func_files [ i ] , split [ n ] ) ) if split [ n ] not in self . code_sections : self . code_sections [ split [ n ] ] = "" self . code_sections [ split [ n ] ] += split [ n + 1 ] n += 2 else : raise ValueError ( "No valid section marker was found in file " "%s" % func_files [ i ] )
Loads the c code to perform the Op
Loads the c code to perform the Op
"""
        Loads the c code to perform the Op
        """ # U (universal) will convert all new lines format to \n. # If both the old section markers and the new section markers are # present, raise an error because we don't know which ones to follow. # This is backward compat code that will go away in a while # Separate the code into the proper sections # Check for code outside of the supported sections # Separate the code into the proper sections
self
func_files