|
155 | 155 | 'build/printf_format', |
156 | 156 | 'build/storage_class', |
157 | 157 | 'caffe/alt_fn', |
| 158 | + 'caffe/data_layer_setup', |
158 | 159 | 'caffe/random_fn', |
159 | 160 | 'legal/copyright', |
160 | 161 | 'readability/alt_tokens', |
@@ -1591,6 +1592,45 @@ def CheckCaffeAlternatives(filename, clean_lines, linenum, error): |
1591 | 1592 | (' or '.join(disp_alts), function)) |
1592 | 1593 |
|
1593 | 1594 |
|
| 1595 | +def CheckCaffeDataLayerSetUp(filename, clean_lines, linenum, error): |
| 1596 | + """Except the base classes, Caffe DataLayer should define DataLayerSetUp |
| 1597 | + instead of LayerSetUp. |
| 1598 | + |
| 1599 | + The base DataLayers define common SetUp steps, the subclasses should |
| 1600 | + not override them. |
| 1601 | + |
| 1602 | + Args: |
| 1603 | + filename: The name of the current file. |
| 1604 | + clean_lines: A CleansedLines instance containing the file. |
| 1605 | + linenum: The number of the line to check. |
| 1606 | + error: The function to call with any errors found. |
| 1607 | + """ |
| 1608 | + line = clean_lines.elided[linenum] |
| 1609 | + ix = line.find('DataLayer<Dtype>::LayerSetUp') |
| 1610 | + if ix >= 0 and ( |
| 1611 | + line.find('void DataLayer<Dtype>::LayerSetUp') != -1 or |
| 1612 | + line.find('void ImageDataLayer<Dtype>::LayerSetUp') != -1 or |
| 1613 | + line.find('void MemoryDataLayer<Dtype>::LayerSetUp') != -1 or |
| 1614 | + line.find('void WindowDataLayer<Dtype>::LayerSetUp') != -1): |
| 1615 | + error(filename, linenum, 'caffe/data_layer_setup', 2, |
| 1616 | + 'Except the base classes, Caffe DataLayer should define' |
| 1617 | + + ' DataLayerSetUp instead of LayerSetUp. The base DataLayers' |
| 1618 | + + ' define common SetUp steps, the subclasses should' |
| 1619 | + + ' not override them.') |
| 1620 | + ix = line.find('DataLayer<Dtype>::DataLayerSetUp') |
| 1621 | + if ix >= 0 and ( |
| 1622 | + line.find('void Base') == -1 and |
| 1623 | + line.find('void DataLayer<Dtype>::DataLayerSetUp') == -1 and |
| 1624 | + line.find('void ImageDataLayer<Dtype>::DataLayerSetUp') == -1 and |
| 1625 | + line.find('void MemoryDataLayer<Dtype>::DataLayerSetUp') == -1 and |
| 1626 | + line.find('void WindowDataLayer<Dtype>::DataLayerSetUp') == -1): |
| 1627 | + error(filename, linenum, 'caffe/data_layer_setup', 2, |
| 1628 | + 'Except the base classes, Caffe DataLayer should define' |
| 1629 | + + ' DataLayerSetUp instead of LayerSetUp. The base DataLayers' |
| 1630 | + + ' define common SetUp steps, the subclasses should' |
| 1631 | + + ' not override them.') |
| 1632 | + |
| 1633 | + |
1594 | 1634 | c_random_function_list = ( |
1595 | 1635 | 'rand(', |
1596 | 1636 | 'rand_r(', |
@@ -4593,6 +4633,7 @@ def ProcessLine(filename, file_extension, clean_lines, line, |
4593 | 4633 | nesting_state, error) |
4594 | 4634 | CheckVlogArguments(filename, clean_lines, line, error) |
4595 | 4635 | CheckCaffeAlternatives(filename, clean_lines, line, error) |
| 4636 | + CheckCaffeDataLayerSetUp(filename, clean_lines, line, error) |
4596 | 4637 | CheckCaffeRandom(filename, clean_lines, line, error) |
4597 | 4638 | CheckPosixThreading(filename, clean_lines, line, error) |
4598 | 4639 | CheckInvalidIncrement(filename, clean_lines, line, error) |
|
0 commit comments