summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorKai Li <kaili_kloud@163.com>2014-08-31 17:47:58 +0800
committerKai Li <kaili_kloud@163.com>2014-09-03 13:25:22 +0800
commit74fa8797739440ea254a59d2bfe801a2bfe870f2 (patch)
tree988b86e10ae74283e0879097ebab735cd9786ee4 /scripts
parent09cfe1ca4b1410fb41b3969ca4e50c34bef9a8ba (diff)
downloadcaffeonacl-74fa8797739440ea254a59d2bfe801a2bfe870f2.tar.gz
caffeonacl-74fa8797739440ea254a59d2bfe801a2bfe870f2.tar.bz2
caffeonacl-74fa8797739440ea254a59d2bfe801a2bfe870f2.zip
Add lint rule for caffe data layer setup
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cpp_lint.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/scripts/cpp_lint.py b/scripts/cpp_lint.py
index 61b8b0cd..1b7c6c05 100755
--- a/scripts/cpp_lint.py
+++ b/scripts/cpp_lint.py
@@ -155,6 +155,7 @@ _ERROR_CATEGORIES = [
'build/printf_format',
'build/storage_class',
'caffe/alt_fn',
+ 'caffe/data_layer_setup',
'caffe/random_fn',
'legal/copyright',
'readability/alt_tokens',
@@ -1591,6 +1592,45 @@ def CheckCaffeAlternatives(filename, clean_lines, linenum, error):
(' or '.join(disp_alts), function))
+def CheckCaffeDataLayerSetUp(filename, clean_lines, linenum, error):
+ """Except the base classes, Caffe DataLayer should define DataLayerSetUp
+ instead of LayerSetUp.
+
+ The base DataLayers define common SetUp steps, the subclasses should
+ not override them.
+
+ Args:
+ filename: The name of the current file.
+ clean_lines: A CleansedLines instance containing the file.
+ linenum: The number of the line to check.
+ error: The function to call with any errors found.
+ """
+ line = clean_lines.elided[linenum]
+ ix = line.find('DataLayer<Dtype>::LayerSetUp')
+ if ix >= 0 and (
+ line.find('void DataLayer<Dtype>::LayerSetUp') != -1 or
+ line.find('void ImageDataLayer<Dtype>::LayerSetUp') != -1 or
+ line.find('void MemoryDataLayer<Dtype>::LayerSetUp') != -1 or
+ line.find('void WindowDataLayer<Dtype>::LayerSetUp') != -1):
+ error(filename, linenum, 'caffe/data_layer_setup', 2,
+ 'Except the base classes, Caffe DataLayer should define'
+ + ' DataLayerSetUp instead of LayerSetUp. The base DataLayers'
+ + ' define common SetUp steps, the subclasses should'
+ + ' not override them.')
+ ix = line.find('DataLayer<Dtype>::DataLayerSetUp')
+ if ix >= 0 and (
+ line.find('void Base') == -1 and
+ line.find('void DataLayer<Dtype>::DataLayerSetUp') == -1 and
+ line.find('void ImageDataLayer<Dtype>::DataLayerSetUp') == -1 and
+ line.find('void MemoryDataLayer<Dtype>::DataLayerSetUp') == -1 and
+ line.find('void WindowDataLayer<Dtype>::DataLayerSetUp') == -1):
+ error(filename, linenum, 'caffe/data_layer_setup', 2,
+ 'Except the base classes, Caffe DataLayer should define'
+ + ' DataLayerSetUp instead of LayerSetUp. The base DataLayers'
+ + ' define common SetUp steps, the subclasses should'
+ + ' not override them.')
+
+
c_random_function_list = (
'rand(',
'rand_r(',
@@ -4593,6 +4633,7 @@ def ProcessLine(filename, file_extension, clean_lines, line,
nesting_state, error)
CheckVlogArguments(filename, clean_lines, line, error)
CheckCaffeAlternatives(filename, clean_lines, line, error)
+ CheckCaffeDataLayerSetUp(filename, clean_lines, line, error)
CheckCaffeRandom(filename, clean_lines, line, error)
CheckPosixThreading(filename, clean_lines, line, error)
CheckInvalidIncrement(filename, clean_lines, line, error)