"...resnet50_tensorflow.git" did not exist on "603d702d48093b9ee0d7dd27ab3acdefcd62c9c8"
Unverified Commit d582425b authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Cppcheck fixes (#1195)

Fixes the #error when using cppcheck. This no longer suppresses cppcheck errors when including those errors. This fixes the cppcheck errors that was there already.
parent 4a5a23a4
...@@ -216,6 +216,7 @@ rocm_enable_cppcheck( ...@@ -216,6 +216,7 @@ rocm_enable_cppcheck(
CPPCHECK=1 CPPCHECK=1
__device__= __device__=
__host__= __host__=
__global__=
) )
enable_testing() enable_testing()
......
...@@ -314,6 +314,7 @@ struct interface_base : Base ...@@ -314,6 +314,7 @@ struct interface_base : Base
T** y = reinterpret_cast<T**>(out); T** y = reinterpret_cast<T**>(out);
T* x = reinterpret_cast<T*>(input); T* x = reinterpret_cast<T*>(input);
assert(x != nullptr and y != nullptr and *y == nullptr); assert(x != nullptr and y != nullptr and *y == nullptr);
// cppcheck-suppress useSmartPointer
*y = new T(*x); // NOLINT *y = new T(*x); // NOLINT
}); });
}; };
...@@ -339,6 +340,7 @@ struct interface_base : Base ...@@ -339,6 +340,7 @@ struct interface_base : Base
template <class T, class Setter, class F> template <class T, class Setter, class F>
void set_auto_fp(Setter setter, F f) void set_auto_fp(Setter setter, F f)
{ {
// cppcheck-suppress constParameter
return set_fp<T>(setter, [=](T& obj, auto out, auto... xs) { return set_fp<T>(setter, [=](T& obj, auto out, auto... xs) {
auto_invoke(f, out, obj, auto_convert_param(rank<2>{}, xs)...); auto_invoke(f, out, obj, auto_convert_param(rank<2>{}, xs)...);
}); });
......
...@@ -17,7 +17,7 @@ class marker_roctx ...@@ -17,7 +17,7 @@ class marker_roctx
std::function<int(const char*)> sym_roctx_range_push; std::function<int(const char*)> sym_roctx_range_push;
std::function<int()> sym_roctx_range_pop; std::function<int()> sym_roctx_range_pop;
uint64_t range_id; uint64_t range_id = 0;
public: public:
marker_roctx() marker_roctx()
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
#include <migraphx/config.hpp> #include <migraphx/config.hpp>
#if defined(__has_include) && !defined(CPPCHECK) #if defined(CPPCHECK)
#define MIGRAPHX_HAS_FILESYSTEM 1
#define MIGRAPHX_HAS_FILESYSTEM_TS 1
#elif defined(__has_include)
#if __has_include(<filesystem>) && __cplusplus >= 201703L #if __has_include(<filesystem>) && __cplusplus >= 201703L
#define MIGRAPHX_HAS_FILESYSTEM 1 #define MIGRAPHX_HAS_FILESYSTEM 1
#else #else
......
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
#include <migraphx/config.hpp> #include <migraphx/config.hpp>
#if defined(__has_include) && !defined(CPPCHECK) #if defined(CPPCHECK)
#define MIGRAPHX_HAS_OPTIONAL 1
#define MIGRAPHX_HAS_OPTIONAL_TS 1
#elif defined(__has_include)
#if __has_include(<optional>) && __cplusplus >= 201703L #if __has_include(<optional>) && __cplusplus >= 201703L
#define MIGRAPHX_HAS_OPTIONAL 1 #define MIGRAPHX_HAS_OPTIONAL 1
#else #else
......
...@@ -24,14 +24,17 @@ struct parse_mean : op_parser<parse_mean> ...@@ -24,14 +24,17 @@ struct parse_mean : op_parser<parse_mean>
auto divisor = info.add_literal( auto divisor = info.add_literal(
migraphx::literal{migraphx::shape{args[0]->get_shape().type()}, {num_data}}); migraphx::literal{migraphx::shape{args[0]->get_shape().type()}, {num_data}});
return std::accumulate(args.begin(), args.end(), args[0], [&](auto& mean, auto& data_i) { // TODO: Only divide when using floating-point
// Pre-divide each tensor element-wise by n to reduce risk of overflow during summation return std::accumulate(args.begin() + 1,
data_i = info.add_broadcastable_binary_op("div", data_i, divisor); args.end(),
info.add_broadcastable_binary_op("div", args[0], divisor),
if(data_i != args[0]) [&](auto mean, auto data_i) {
return info.add_broadcastable_binary_op("add", mean, data_i); // Pre-divide each tensor element-wise by n to reduce risk of
return data_i; // overflow during summation
}); auto div =
info.add_broadcastable_binary_op("div", data_i, divisor);
return info.add_broadcastable_binary_op("add", mean, div);
});
} }
}; };
......
...@@ -995,7 +995,7 @@ struct find_split_transpose ...@@ -995,7 +995,7 @@ struct find_split_transpose
auto axis = any_cast<op::slice>(slc->get_operator()).axes.front(); auto axis = any_cast<op::slice>(slc->get_operator()).axes.front();
auto it = std::find(perm.begin(), perm.end(), axis); auto it = std::find(perm.begin(), perm.end(), axis);
assert(it != perm.end()); assert(it != perm.end());
auto axis_new = static_cast<int64_t>(std::distance(perm.begin(), it)); int64_t axis_new = std::distance(perm.begin(), it);
for(auto in : split_outputs) for(auto in : split_outputs)
{ {
......
...@@ -133,6 +133,7 @@ struct hiprtc_program ...@@ -133,6 +133,7 @@ struct hiprtc_program
std::vector<char> buffer(n); std::vector<char> buffer(n);
MIGRAPHX_HIPRTC(hiprtcGetProgramLog(prog.get(), buffer.data())); MIGRAPHX_HIPRTC(hiprtcGetProgramLog(prog.get(), buffer.data()));
assert(buffer.back() == 0); assert(buffer.back() == 0);
// cppcheck-suppress returnDanglingLifetime
return {buffer.begin(), buffer.end() - 1}; return {buffer.begin(), buffer.end() - 1};
} }
......
...@@ -118,15 +118,13 @@ constexpr roalign_settings<Ts...> make_roalign_settings(Ts... xs) ...@@ -118,15 +118,13 @@ constexpr roalign_settings<Ts...> make_roalign_settings(Ts... xs)
} }
template <class T, class U, class V, class W, class Settings> template <class T, class U, class V, class W, class Settings>
__device__ void roialign(const T& x_t, const U& rois_t, const V& ind_t, const W& y_t, Settings s) __device__ void roialign(const T& x_t, const U& rois_t, const V& ind_t, W& y_t, Settings s)
{ {
auto index = make_index(); auto index = make_index();
const auto x = x_t.begin(); const auto x = x_t.begin();
const auto rois = rois_t.begin(); const auto rois = rois_t.begin();
const auto ind = ind_t.begin(); const auto ind = ind_t.begin();
auto out_ptr = y_t.begin();
// input shape // input shape
auto x_lens = x_t.get_shape().lens; auto x_lens = x_t.get_shape().lens;
auto channel_num = x_lens[1]; auto channel_num = x_lens[1];
...@@ -176,25 +174,25 @@ __device__ void roialign(const T& x_t, const U& rois_t, const V& ind_t, const W& ...@@ -176,25 +174,25 @@ __device__ void roialign(const T& x_t, const U& rois_t, const V& ind_t, const W&
const auto offset_x = x + ((batch_ind * channel_num + c) * in_dims[0] * in_dims[1]); const auto offset_x = x + ((batch_ind * channel_num + c) * in_dims[0] * in_dims[1]);
if constexpr(s.is_avg_pooling) if constexpr(s.is_avg_pooling)
{ {
out_ptr[i] = calc_pooling(offset_x, y_t[i] = calc_pooling(offset_x,
roi_starts, roi_starts,
bin_size, bin_size,
{ph, pw}, {ph, pw},
bin_grid_size, bin_grid_size,
in_dims, in_dims,
s.roi_offset, s.roi_offset,
avg_pool{}); avg_pool{});
} }
else else
{ {
out_ptr[i] = calc_pooling(offset_x, y_t[i] = calc_pooling(offset_x,
roi_starts, roi_starts,
bin_size, bin_size,
{ph, pw}, {ph, pw},
bin_grid_size, bin_grid_size,
in_dims, in_dims,
s.roi_offset, s.roi_offset,
max_pool{}); max_pool{});
} }
} }
} }
......
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