Commit ef5d7092 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

Merge branch 'develop' of https://github.com/ROCmSoftwarePlatform/AMDMIGraphX...

Merge branch 'develop' of https://github.com/ROCmSoftwarePlatform/AMDMIGraphX into refine_eliminate_contiguous
parents 2e04ea47 b2051bbc
...@@ -3,6 +3,8 @@ CheckOptions: ...@@ -3,6 +3,8 @@ CheckOptions:
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::find;::std::find_if;::std::find_if_not;::std::all_of;::std::any_of;::std::none_of;::std::count;::std::count_if;::std::mismatch;::std::find_end;::std::find_first_of;::std::adjacent_find;::std::search;::std::search_n;::std::nth_element;::std::lower_bound;::std::upper_bound;::std::binary_search;::std::equal_range;::std::max;::std::max_element;::std::min;::std::min_element;::std::minmax;::std::minmax_element;::std::equal;::std::lexicographical_compare;::std::accumulate;::std::inner_product' value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::find;::std::find_if;::std::find_if_not;::std::all_of;::std::any_of;::std::none_of;::std::count;::std::count_if;::std::mismatch;::std::find_end;::std::find_first_of;::std::adjacent_find;::std::search;::std::search_n;::std::nth_element;::std::lower_bound;::std::upper_bound;::std::binary_search;::std::equal_range;::std::max;::std::max_element;::std::min;::std::min_element;::std::minmax;::std::minmax_element;::std::equal;::std::lexicographical_compare;::std::accumulate;::std::inner_product'
- key: cppcoreguidelines-macro-usage.AllowedRegexp - key: cppcoreguidelines-macro-usage.AllowedRegexp
value: 'DEBUG|FALLTHROUGH|_THROW|_REQUIRES|_DECLARE_|_VISIT_|_GENERATE_|_DETAIL_|_MANAGE_PTR|_MATCHER|DEVICE_SHARED' value: 'DEBUG|FALLTHROUGH|_THROW|_REQUIRES|_DECLARE_|_VISIT_|_GENERATE_|_DETAIL_|_MANAGE_PTR|_MATCHER|DEVICE_SHARED'
- key: cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
value: 0
- key: modernize-loop-convert.MinConfidence - key: modernize-loop-convert.MinConfidence
value: risky value: risky
- key: modernize-loop-convert.NamingStyle - key: modernize-loop-convert.NamingStyle
......
...@@ -56,6 +56,7 @@ rocm_enable_clang_tidy( ...@@ -56,6 +56,7 @@ rocm_enable_clang_tidy(
-clang-diagnostic-extern-c-compat -clang-diagnostic-extern-c-compat
-clang-diagnostic-disabled-macro-expansion -clang-diagnostic-disabled-macro-expansion
-clang-diagnostic-unused-command-line-argument -clang-diagnostic-unused-command-line-argument
-cppcoreguidelines-explicit-virtual-functions
-cppcoreguidelines-pro-bounds-array-to-pointer-decay -cppcoreguidelines-pro-bounds-array-to-pointer-decay
-cppcoreguidelines-pro-bounds-constant-array-index -cppcoreguidelines-pro-bounds-constant-array-index
-cppcoreguidelines-pro-bounds-pointer-arithmetic -cppcoreguidelines-pro-bounds-pointer-arithmetic
...@@ -83,6 +84,7 @@ rocm_enable_clang_tidy( ...@@ -83,6 +84,7 @@ rocm_enable_clang_tidy(
-modernize-pass-by-value -modernize-pass-by-value
-modernize-use-default-member-init -modernize-use-default-member-init
-modernize-use-transparent-functors -modernize-use-transparent-functors
-performance-type-promotion-in-math-fn
-readability-braces-around-statements -readability-braces-around-statements
-readability-else-after-return -readability-else-after-return
-readability-named-parameter -readability-named-parameter
......
...@@ -44,13 +44,14 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow- ...@@ -44,13 +44,14 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
# Install cget # Install cget
RUN pip install cget # RUN pip install cget
RUN pip install https://github.com/pfultz2/cget/archive/57b3289000fcdb3b7e424c60a35ea09bc44d8538.tar.gz
# Install rclone # Install rclone
RUN pip install https://github.com/pfultz2/rclone/archive/master.tar.gz RUN pip install https://github.com/pfultz2/rclone/archive/master.tar.gz
# Install hcc # Install hcc
RUN rclone -b roc-2.0.x -c 757fb492517b80e7c86338af5fc1a43d63cb25a9 https://github.com/RadeonOpenCompute/hcc.git /hcc RUN rclone -b roc-2.3.x -c fd93baed7dcc4fe8019b5fdc90213bfe7c298245 https://github.com/RadeonOpenCompute/hcc.git /hcc
RUN cget -p $PREFIX install hcc,/hcc RUN cget -p $PREFIX install hcc,/hcc
# Use hcc # Use hcc
......
...@@ -90,6 +90,7 @@ else() ...@@ -90,6 +90,7 @@ else()
-Wno-double-promotion -Wno-double-promotion
-Wno-exit-time-destructors -Wno-exit-time-destructors
-Wno-extra-semi -Wno-extra-semi
-Wno-extra-semi-stmt
-Wno-float-conversion -Wno-float-conversion
-Wno-gnu-anonymous-struct -Wno-gnu-anonymous-struct
-Wno-gnu-zero-variadic-macro-arguments -Wno-gnu-zero-variadic-macro-arguments
...@@ -104,7 +105,7 @@ else() ...@@ -104,7 +105,7 @@ else()
else() else()
list(APPEND CMAKE_COMPILER_WARNINGS list(APPEND CMAKE_COMPILER_WARNINGS
-Wno-missing-field-initializers -Wno-missing-field-initializers
-Wno-deprecated-declarations # -Wno-deprecated-declarations
) )
endif() endif()
add_definitions(${CMAKE_COMPILER_WARNINGS}) add_definitions(${CMAKE_COMPILER_WARNINGS})
......
...@@ -89,49 +89,76 @@ ...@@ -89,49 +89,76 @@
<summary>Use manage pointer for resource management</summary> <summary>Use manage pointer for resource management</summary>
</message> </message>
</rule> </rule>
<rule>
<tokenlist>raw</tokenlist>
<pattern><![CDATA[hipLaunchKernelGGL \( (?!\( \w+ < \w+ > \))]]></pattern>
<message>
<id>UseDeviceLaunch</id>
<severity>style</severity>
<summary>Use device::launch instead</summary>
</message>
</rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern>! !</pattern> <pattern><![CDATA[if (\([^()]*(?-1)*[^()]*\)) { [^{}]* (return|throw|break|continue) [^;]* ; } else {]]></pattern>
<message> <message>
<id>doubleNegative</id> <id>UnnecessaryElseStatement</id>
<severity>style</severity> <severity>style</severity>
<summary>Double negative is always positive</summary> <summary>Else statement is not necessary.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( \w+ (\||&) \w+ \)]]></pattern> <pattern><![CDATA[\? (true|false) : (true|false)]]></pattern>
<message> <message>
<id>BitwiseOperatorInConditional</id> <id>RedundantConditionalOperator</id>
<severity>style</severity> <severity>style</severity>
<summary>Bitwise operator found in if statement.</summary> <summary>Conditional operator is redundant.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( [^)]+ \) { if \( [^)]+ \) ({[^{}]*(?1)*[^{}]*}) }]]></pattern> <pattern><![CDATA[switch (\([^()]*(?-1)*[^()]*\)) { }]]></pattern>
<message> <message>
<id>CollapsibleIfStatements</id> <id>EmptySwitchStatement</id>
<severity>style</severity> <severity>style</severity>
<summary>These two if statements can be collapsed into one.</summary> <summary>Empty switch statement.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[catch \( [^())]+ \) { }]]></pattern> <pattern><![CDATA[(?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w) ; \1 = [^;]+ ; return \1 ;]]></pattern>
<message> <message>
<id>EmptyCatchStatement</id> <id>RedundantLocalVariable</id>
<severity>style</severity> <severity>style</severity>
<summary>An empty catch statement.</summary> <summary>Variable is returned immediately after its declaration, can be simplified to just return expression.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[do { } while \(]]></pattern> <pattern><![CDATA[for \( ; [^;]+ ; \)]]></pattern>
<message> <message>
<id>EmptyDoWhileStatement</id> <id>ForLoopShouldBeWhileLoop</id>
<severity>style</severity> <severity>style</severity>
<summary>Empty do-while.</summary> <summary>For loop should be written as a while loop.</summary>
</message>
</rule>
<rule>
<tokenlist>normal</tokenlist>
<pattern><![CDATA[while (\([^()]*(?-1)*[^()]*\)) { }]]></pattern>
<message>
<id>EmptyWhileStatement</id>
<severity>style</severity>
<summary>Empty while statement.</summary>
</message>
</rule>
<rule>
<tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( \w+ (\||&) \w+ \)]]></pattern>
<message>
<id>BitwiseOperatorInConditional</id>
<severity>style</severity>
<summary>Bitwise operator found in if statement.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
...@@ -145,7 +172,7 @@ ...@@ -145,7 +172,7 @@
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[for \( [^()]+ \) { }]]></pattern> <pattern><![CDATA[for (\([^()]*(?-1)*[^()]*\)) { }]]></pattern>
<message> <message>
<id>EmptyForStatement</id> <id>EmptyForStatement</id>
<severity>style</severity> <severity>style</severity>
...@@ -154,7 +181,7 @@ ...@@ -154,7 +181,7 @@
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( [^()]+ \) { }]]></pattern> <pattern><![CDATA[if (\([^()]*(?-1)*[^()]*\)) { }]]></pattern>
<message> <message>
<id>EmptyIfStatement</id> <id>EmptyIfStatement</id>
<severity>style</severity> <severity>style</severity>
...@@ -163,43 +190,52 @@ ...@@ -163,43 +190,52 @@
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[switch \( [^()]+ \) { }]]></pattern> <pattern><![CDATA[if (\([^()]*(?-1)*[^()]*\)) { return (true|false) ; } else { return (true|false) ; }]]></pattern>
<message> <message>
<id>EmptySwitchStatement</id> <id>RedundantIfStatement</id>
<severity>style</severity> <severity>style</severity>
<summary>Empty switch statement.</summary> <summary>The if statement is redundant.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[while \( [^()]+ \) { }]]></pattern> <pattern><![CDATA[! !]]></pattern>
<message> <message>
<id>EmptyWhileStatement</id> <id>DoubleNegative</id>
<severity>style</severity> <severity>style</severity>
<summary>Empty while statement.</summary> <summary>Double negative is always positive.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[ for \( ; [^;]+ ; \)]]></pattern> <pattern><![CDATA[~ ~]]></pattern>
<message> <message>
<id>ForLoopShouldBeWhileLoop</id> <id>DoubleNegative</id>
<severity>style</severity> <severity>style</severity>
<summary>For loop should be written as a while loop.</summary> <summary>Double negative is always positive.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern>goto</pattern> <pattern><![CDATA[! \( !]]></pattern>
<message> <message>
<id>GotoStatement</id> <id>DoubleNegative</id>
<severity>style</severity> <severity>style</severity>
<summary>Goto considered harmful.</summary> <summary>Double negative is always positive.</summary>
</message>
</rule>
<rule>
<tokenlist>normal</tokenlist>
<pattern><![CDATA[~ \( ~]]></pattern>
<message>
<id>DoubleNegative</id>
<severity>style</severity>
<summary>Double negative is always positive.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( \w+ != \w+ \) ({[^{}]*(?1)*[^{}]*}) else { (?!if)]]></pattern> <pattern><![CDATA[if \( \w+ != \w+ \) ({[^{}]*(?-1)*[^{}]*}) else { (?!if)]]></pattern>
<message> <message>
<id>InvertedLogic</id> <id>InvertedLogic</id>
<severity>style</severity> <severity>style</severity>
...@@ -208,7 +244,7 @@ ...@@ -208,7 +244,7 @@
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( ! \w+ \) ({[^{}]*(?1)*[^{}]*}) else { (?!if)]]></pattern> <pattern><![CDATA[if \( ! \w+ \) ({[^{}]*(?-1)*[^{}]*}) else { (?!if)]]></pattern>
<message> <message>
<id>InvertedLogic</id> <id>InvertedLogic</id>
<severity>style</severity> <severity>style</severity>
...@@ -235,34 +271,43 @@ ...@@ -235,34 +271,43 @@
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[\? (true|false) : (true|false)]]></pattern> <pattern><![CDATA[catch (\([^()]*(?-1)*[^()]*\)) { }]]></pattern>
<message> <message>
<id>RedundantConditionalOperator</id> <id>EmptyCatchStatement</id>
<severity>style</severity> <severity>style</severity>
<summary>Conditional operator is redundant.</summary> <summary>An empty catch statement.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( [^()]+ \) { return (true|false) ; } else { return (true|false) ; }]]></pattern> <pattern><![CDATA[if (\([^()]*(?-1)*[^()]*\)) { assert (\([^()]*(?-1)*[^()]*\)) ; }]]></pattern>
<message> <message>
<id>RedundantIfStatement</id> <id>ConditionalAssert</id>
<severity>style</severity> <severity>style</severity>
<summary>The if statement is redundant.</summary> <summary>The if condition should be included in assert.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[if \( [^()]+ \) { [^{}]* (return|throw|break|continue) [^;]* ; } else {]]></pattern> <pattern><![CDATA[if \( (\w) . empty \( \) \) { for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* \w : \1 \) ({[^{}]*(?-1)*[^{}]*}) }]]></pattern>
<message> <message>
<id>UnnecessaryElseStatement</id> <id>UnnecessaryEmptyCondition</id>
<severity>style</severity> <severity>style</severity>
<summary>Else statement is not necessary.</summary> <summary>Unnecessary check for empty before for range loop.</summary>
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>normal</tokenlist>
<pattern><![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = \w+ \[ \1 \] ; }]]></pattern> <pattern><![CDATA[if \( ! (\w) . empty \( \) \) { for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* \w : \1 \) ({[^{}]*(?-1)*[^{}]*}) }]]></pattern>
<message>
<id>UnnecessaryEmptyCondition</id>
<severity>style</severity>
<summary>Unnecessary check for empty before for range loop.</summary>
</message>
</rule>
<rule>
<tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = \w+ \[ \1 \] ; }]]></pattern>
<message> <message>
<id>useStlAlgorithm</id> <id>useStlAlgorithm</id>
<severity>style</severity> <severity>style</severity>
...@@ -270,8 +315,8 @@ ...@@ -270,8 +315,8 @@
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = \w+ ; }]]></pattern> <pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = \w+ ; }]]></pattern>
<message> <message>
<id>useStlAlgorithm</id> <id>useStlAlgorithm</id>
<severity>style</severity> <severity>style</severity>
...@@ -279,8 +324,8 @@ ...@@ -279,8 +324,8 @@
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (\w+ :: )*\w+ \( \) ; }]]></pattern> <pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (?:\w+ :: )*\w+ \( \) ; }]]></pattern>
<message> <message>
<id>useStlAlgorithm</id> <id>useStlAlgorithm</id>
<severity>style</severity> <severity>style</severity>
...@@ -288,8 +333,8 @@ ...@@ -288,8 +333,8 @@
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (\w+ :: )*\w+ \( \w+ \[ \1 \] \) ; }]]></pattern> <pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (?:\w+ :: )*\w+ \( \w+ \[ \1 \] \) ; }]]></pattern>
<message> <message>
<id>useStlAlgorithm</id> <id>useStlAlgorithm</id>
<severity>style</severity> <severity>style</severity>
...@@ -297,11 +342,65 @@ ...@@ -297,11 +342,65 @@
</message> </message>
</rule> </rule>
<rule> <rule>
<tokenlist>normal</tokenlist> <tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( \w+ (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (\w+ :: )*\w+ \( \w+ \[ \1 \] , \w+ \[ \1 \] \) ; }]]></pattern> <pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) = \w+ ; \1 < \w+ ; (\1 \+\+|\+\+ \1|\1 \-\-|\-\- \1) \) { \w+ \[ \1 \] = (?:\w+ :: )*\w+ \( \w+ \[ \1 \] , \w+ \[ \1 \] \) ; }]]></pattern>
<message> <message>
<id>useStlAlgorithm</id> <id>useStlAlgorithm</id>
<severity>style</severity> <severity>style</severity>
<summary>Considering using std::transform instead.</summary> <summary>Considering using std::transform instead.</summary>
</message> </message>
</rule> </rule>
<rule>
<tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) : (?:[^()]*(\([^()]*(?-1)*[^()]*\)))*[^)]*\) { (?:(?<idx1>\w+) \+\+|\+\+ (?<idx2>\w+)) ; if (\([^()]*(?-1)*[^()]*\)) { \w+ = \g{idx1}|\g{idx2} ; (?:break ; )?(?:return [^;]*; )?} }]]></pattern>
<message>
<id>useStlAlgorithm</id>
<severity>style</severity>
<summary>Considering using std::find or std::find_if instead.</summary>
</message>
</rule>
<rule>
<tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) : (?:[^()]*(\([^()]*(?-1)*[^()]*\)))*[^)]*\) { if (\([^()]*(?-1)*[^()]*\)) { \w+ = (?<idx>\w) ; (?:break ; )?(?:return [^;]*; )?} (?:(\g{idx}) \+\+|\+\+ (\g{idx})) ; }]]></pattern>
<message>
<id>useStlAlgorithm</id>
<severity>style</severity>
<summary>Considering using std::find or std::find_if instead.</summary>
</message>
</rule>
<rule>
<tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) : (?:[^()]*(\([^()]*(?-1)*[^()]*\)))*[^)]*\) { (?:(?<idx1>\w+) \+\+|\+\+ (?<idx2>\w+)) ; if (\([^()]*(?-1)*[^()]*\)) { return \g{idx1}|\g{idx2} ; } }]]></pattern>
<message>
<id>useStlAlgorithm</id>
<severity>style</severity>
<summary>Considering using std::find or std::find_if instead.</summary>
</message>
</rule>
<rule>
<tokenlist>simple</tokenlist>
<pattern><![CDATA[for \( (?:(?:\w+|<|>|::) )*(?:\w+|>)(?: &|\*)* (\w+) : (?:[^()]*(\([^()]*(?-1)*[^()]*\)))*[^)]*\) { if (\([^()]*(?-1)*[^()]*\)) { return (?<idx>\w+) ; } (?:(\g{idx}) \+\+|\+\+ (\g{idx})) ; }]]></pattern>
<message>
<id>useStlAlgorithm</id>
<severity>style</severity>
<summary>Considering using std::find or std::find_if instead.</summary>
</message>
</rule>
<rule>
<tokenlist>normal</tokenlist>
<pattern><![CDATA[do { } while \(]]></pattern>
<message>
<id>EmptyDoWhileStatement</id>
<severity>style</severity>
<summary>Empty do-while.</summary>
</message>
</rule>
<rule>
<tokenlist>normal</tokenlist>
<pattern>goto</pattern>
<message>
<id>GotoStatement</id>
<severity>style</severity>
<summary>Goto considered harmful.</summary>
</message>
</rule>
pfultz2/rocm-recipes pfultz2/rocm-recipes
danmar/cppcheck@681cb7dd909d1bfe41796b7616e43265177b9464 -DHAVE_RULES=1 danmar/cppcheck@8aa68ee297c2d9ebadf5bcfd00c66ea8d9291e35 -DHAVE_RULES=1
ROCm-Developer-Tools/HIP@fc22ef991ce7cb15821c8ccb4f03cdfc3e7e43cf ROCm-Developer-Tools/HIP@e21df3058728ad8e73708bc99b82e0bdd3509c97
python/cpython@v3.6.6 -X autotools -H sha256:92aa914572c695c0aeb01b0a214813f414da4b51a371234df514a74761f2bb36 python/cpython@v3.6.6 -X autotools -H sha256:92aa914572c695c0aeb01b0a214813f414da4b51a371234df514a74761f2bb36
-f requirements.txt -f requirements.txt
...@@ -17,7 +17,7 @@ constexpr T normalize(unsigned long z) ...@@ -17,7 +17,7 @@ constexpr T normalize(unsigned long z)
return T(0); return T(0);
const auto max = 32; const auto max = 32;
const double range = max / 2; // NOLINT const double range = max / 2; // NOLINT
double result = (z % max) / range; double result = double(z % max) / range;
result -= 1; result -= 1;
return T(result); return T(result);
} }
......
...@@ -72,7 +72,9 @@ struct instruction ...@@ -72,7 +72,9 @@ struct instruction
static void static void
replace(instruction_ref ins, operation o, const shape& r, std::vector<instruction_ref> args); replace(instruction_ref ins, operation o, const shape& r, std::vector<instruction_ref> args);
argument eval() const; bool can_eval() const;
argument eval(bool check_eval = true) const;
void finalize(context& ctx); void finalize(context& ctx);
......
#ifndef MIGRAPHX_GUARD_RTGLIB_INT_DIVIDE_HPP
#define MIGRAPHX_GUARD_RTGLIB_INT_DIVIDE_HPP
#include <migraphx/config.hpp>
#include <cmath>
namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
template <class R, class T, class U>
R floor_divide(T x, U y)
{
return R(std::floor(double(x) / double(y)));
}
template <class R, class T, class U>
R ceil_divide(T x, U y)
{
return R(std::ceil(double(x) / double(y)));
}
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
#endif
...@@ -36,7 +36,7 @@ struct as_shape ...@@ -36,7 +36,7 @@ struct as_shape
{ {
return {std::move(output_shape), std::move(args.front().data)}; return {std::move(output_shape), std::move(args.front().data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -63,7 +63,7 @@ struct broadcast ...@@ -63,7 +63,7 @@ struct broadcast
{ {
return {std::move(output_shape), std::move(args.at(0).data)}; return {std::move(output_shape), std::move(args.at(0).data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -46,7 +46,7 @@ struct flatten ...@@ -46,7 +46,7 @@ struct flatten
{ {
return {std::move(output_shape), std::move(args.front().data)}; return {std::move(output_shape), std::move(args.front().data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -24,7 +24,7 @@ struct identity ...@@ -24,7 +24,7 @@ struct identity
{ {
return {std::move(output_shape), std::move(args.at(0).data)}; return {std::move(output_shape), std::move(args.at(0).data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -39,7 +39,7 @@ struct load ...@@ -39,7 +39,7 @@ struct load
MIGRAPHX_THROW("Load access is out of bounds"); MIGRAPHX_THROW("Load access is out of bounds");
return {s, args[0].data() + offset}; return {s, args[0].data() + offset};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
friend std::ostream& operator<<(std::ostream& os, const load& op) friend std::ostream& operator<<(std::ostream& os, const load& op)
{ {
......
...@@ -42,7 +42,7 @@ struct multibroadcast ...@@ -42,7 +42,7 @@ struct multibroadcast
std::vector<size_t> bcast_strides(output_lens.size(), 0); std::vector<size_t> bcast_strides(output_lens.size(), 0);
auto offset = output_lens.size() - input.lens().size(); auto offset = output_lens.size() - input.lens().size();
for(int i = input.lens().size() - 1; i >= 0; i--) for(std::ptrdiff_t i = input.lens().size() - 1; i >= 0; i--)
{ {
if(output_lens[i + offset] == input.lens()[i]) if(output_lens[i + offset] == input.lens()[i])
{ {
...@@ -55,7 +55,7 @@ struct multibroadcast ...@@ -55,7 +55,7 @@ struct multibroadcast
{ {
return {std::move(output_shape), std::move(args.at(0).data)}; return {std::move(output_shape), std::move(args.at(0).data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <migraphx/streamutils.hpp> #include <migraphx/streamutils.hpp>
#include <migraphx/literal.hpp> #include <migraphx/literal.hpp>
#include <migraphx/shape_for_each.hpp> #include <migraphx/shape_for_each.hpp>
#include <migraphx/int_divide.hpp>
#include <migraphx/config.hpp> #include <migraphx/config.hpp>
#include <cmath> #include <cmath>
#include <utility> #include <utility>
...@@ -48,35 +49,6 @@ struct pooling ...@@ -48,35 +49,6 @@ struct pooling
assert(lengths[1] <= (input.lens()[3] + 2 * padding[1])); assert(lengths[1] <= (input.lens()[3] + 2 * padding[1]));
if(padding_mode == default_) if(padding_mode == default_)
{
return {
t,
{
input.lens()[0],
input.lens()[1],
std::size_t(std::max<std::ptrdiff_t>(
1,
std::ptrdiff_t(std::floor((input.lens()[2] + 2 * padding[0] - lengths[0]) /
static_cast<float>(stride[0]))) +
1)),
std::size_t(std::max<std::ptrdiff_t>(
1,
std::ptrdiff_t(std::floor((input.lens()[3] + 2 * padding[1] - lengths[1]) /
static_cast<float>(stride[1]))) +
1)),
}};
}
else if(padding_mode == same)
{
return {t,
{input.lens()[0],
input.lens()[1],
static_cast<std::size_t>(
std::ceil(static_cast<double>(input.lens()[2]) / stride[0])),
static_cast<std::size_t>(
std::ceil(static_cast<double>(input.lens()[3]) / stride[1]))}};
}
else if(padding_mode == valid)
{ {
return {t, return {t,
{ {
...@@ -84,16 +56,39 @@ struct pooling ...@@ -84,16 +56,39 @@ struct pooling
input.lens()[1], input.lens()[1],
std::size_t(std::max<std::ptrdiff_t>( std::size_t(std::max<std::ptrdiff_t>(
1, 1,
std::ptrdiff_t(std::floor((input.lens()[2] - lengths[0]) / floor_divide<std::ptrdiff_t>(
static_cast<float>(stride[0]))) + input.lens()[2] + 2 * padding[0] - lengths[0], stride[0]) +
1)), 1)),
std::size_t(std::max<std::ptrdiff_t>( std::size_t(std::max<std::ptrdiff_t>(
1, 1,
std::ptrdiff_t(std::floor((input.lens()[3] - lengths[1]) / floor_divide<std::ptrdiff_t>(
static_cast<float>(stride[1]))) + input.lens()[3] + 2 * padding[1] - lengths[1], stride[1]) +
1)), 1)),
}}; }};
} }
else if(padding_mode == same)
{
return {t,
{input.lens()[0],
input.lens()[1],
ceil_divide<std::size_t>(input.lens()[2], stride[0]),
ceil_divide<std::size_t>(input.lens()[3], stride[1])}};
}
else if(padding_mode == valid)
{
return {
t,
{
input.lens()[0],
input.lens()[1],
std::size_t(std::max<std::ptrdiff_t>(
1,
floor_divide<std::ptrdiff_t>(input.lens()[2] - lengths[0], stride[0]) + 1)),
std::size_t(std::max<std::ptrdiff_t>(
1,
floor_divide<std::ptrdiff_t>(input.lens()[3] - lengths[1], stride[1]) + 1)),
}};
}
else else
{ {
MIGRAPHX_THROW("Invalid padding mode"); MIGRAPHX_THROW("Invalid padding mode");
......
...@@ -66,7 +66,7 @@ struct reshape ...@@ -66,7 +66,7 @@ struct reshape
{ {
return {std::move(output_shape), std::move(args.front().data)}; return {std::move(output_shape), std::move(args.front().data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -40,7 +40,7 @@ struct scalar ...@@ -40,7 +40,7 @@ struct scalar
{ {
return {std::move(output_shape), std::move(args.at(0).data)}; return {std::move(output_shape), std::move(args.at(0).data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -86,7 +86,7 @@ struct slice ...@@ -86,7 +86,7 @@ struct slice
auto offset = compute_offset(input.get_shape()) * output_shape.type_size(); auto offset = compute_offset(input.get_shape()) * output_shape.type_size();
return {std::move(output_shape), [=] { return input.data() + offset; }}; return {std::move(output_shape), [=] { return input.data() + offset; }};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
...@@ -69,7 +69,7 @@ struct squeeze ...@@ -69,7 +69,7 @@ struct squeeze
{ {
return {std::move(output_shape), std::move(args.front().data)}; return {std::move(output_shape), std::move(args.front().data)};
} }
int output_alias(const std::vector<shape>&) const { return 0; } std::ptrdiff_t output_alias(const std::vector<shape>&) const { return 0; }
}; };
} // namespace op } // namespace op
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment