Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit c9035d1

Browse files
committed
Reduce the number of C++ warnings.
1 parent b76daa2 commit c9035d1

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

_unittests/ut_sklapi/test_onnx_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ def test_pipeline_pickable_options(self):
171171
sess = OnnxInference(model_def)
172172
res = sess.run({'X': X})
173173
self.assertEqual(list(sorted(res)), ['label', 'probabilities'])
174-
self.assertEqualArray(res["label"], pipe.predict(X))
175174
self.assertEqualArray(res["probabilities"], pipe.predict_proba(X))
175+
self.assertEqualArray(res["label"], pipe.predict(X))
176176

177177
def test_pipeline_iris_column_transformer(self):
178178
iris = load_iris()
@@ -243,5 +243,5 @@ def cache(self, obj):
243243

244244

245245
if __name__ == '__main__':
246-
TestOnnxPipeline().test_pipeline_none_params()
246+
# TestOnnxPipeline().test_pipeline_pickable_options()
247247
unittest.main()

mlprodict/onnxrt/ops_cpu/op_conv_transpose_.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ py::array_t<T> ConvTranspose<T>::compute(py::array_t<T, py::array::c_style | py:
140140
std::vector<int64_t> w_dims;
141141
arrayshape2vector(w_dims, W);
142142

143-
const int64_t N = x_dims[0];
143+
// const int64_t N = x_dims[0];
144144
// const int64_t C = x_dims[1];
145-
const int64_t M = w_dims[1];
145+
// const int64_t M = w_dims[1];
146146

147147
std::vector<int64_t> input_shape(x_dims.begin() + 2, x_dims.end());
148148

@@ -256,13 +256,13 @@ void ConvTranspose<T>::compute_gil_free(
256256

257257
const int64_t N = x_dims[0];
258258
const int64_t C = x_dims[1];
259-
const int64_t num_input_channels = C;
259+
// const int64_t num_input_channels = C;
260260
const int64_t num_output_channels = w_dims[1] * group_;
261261
const int64_t M = w_dims[0];
262262

263263
const int64_t input_shape_size = flattened_dimension(input_shape);
264264
const int64_t output_image_size = flattened_dimension(y_dims, 2);
265-
const int64_t output_shape_size = flattened_dimension(output_shape);
265+
// const int64_t output_shape_size = flattened_dimension(output_shape);
266266
const int64_t y_size = flattened_dimension(y_dims);
267267
const int64_t kernel_size = flattened_dimension(kernel_shape);
268268
const int64_t X_offset = C / group_ * input_shape_size;
@@ -286,7 +286,7 @@ void ConvTranspose<T>::compute_gil_free(
286286

287287
std::fill(Ydata, Ydata + y_size, (T)0);
288288

289-
const size_t kernel_rank = kernel_shape.size();
289+
// const size_t kernel_rank = kernel_shape.size();
290290

291291
std::vector<int64_t> output_shape2(y_dims.begin() + 1, y_dims.end());
292292
output_shape2[0] /= group_;

mlprodict/onnxrt/ops_cpu/op_gather_.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void GatherCopyData(const py::array_t<int64_t, py::array::c_style | py::array::f
115115
int64_t idx = indices_data[i];
116116
if (idx < -axis_dim_limit || idx >= axis_dim_limit) {
117117
char buffer[1000];
118-
sprintf(buffer, "Indices element out of data bounds, idx=%d must be within the inclusive range [%d,%d]",
118+
sprintf(buffer, "Indices element out of data bounds, idx=%ld must be within the inclusive range [%ld,%ld]",
119119
idx, -axis_dim_limit, axis_dim_limit-1);
120120
}
121121
}

mlprodict/onnxrt/ops_cpu/op_tfidfvectorizer_.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ void RuntimeTfIdfVectorizer::Init(
213213
auto items = end_idx - start_idx;
214214
if (items > 0) {
215215
auto ngrams = items / ngram_size;
216-
if (ngram_size >= min_gram_length && ngram_size <= max_gram_length)
216+
if ((int)ngram_size >= min_gram_length && (int)ngram_size <= max_gram_length)
217217
ngram_id = PopulateGrams<int64_t>(
218218
pool_int64s.begin() + start_idx, ngrams, ngram_size,
219219
ngram_id, int64_map_);

mlprodict/onnxrt/ops_cpu/op_tree_ensemble_common_p_.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ void RuntimeTreeEnsembleCommonP<NTYPE>::compute_gil_free(
667667
&has_scores[th * n_targets_or_classes_]);
668668
}
669669

670-
for (size_t th = 1; th < nth; ++th) {
670+
if (nth <= 0)
671+
throw std::runtime_error("nth must strictly positive.");
672+
for (size_t th = 1; th < (size_t)nth; ++th) {
671673
agg.MergePrediction(n_targets_or_classes_,
672674
scores.data(), has_scores.data(),
673675
&scores[th * n_targets_or_classes_],
@@ -897,6 +899,9 @@ void RuntimeTreeEnsembleCommonP<NTYPE>::compute_gil_free_array_structure(
897899
}
898900
else if (para_tree_ && (omp_get_max_threads() > 1) && (n_trees_ > omp_tree_)) { DEBUGPRINT("T")
899901
auto nth = omp_get_max_threads();
902+
if (nth <= 0)
903+
throw std::runtime_error("nth must strictly positive.");
904+
900905
auto size_obs = N * n_targets_or_classes_;
901906
std::vector<NTYPE> local_scores(nth * size_obs, 0);
902907
std::vector<unsigned char> local_has_scores(local_scores.size(), 0);
@@ -929,7 +934,7 @@ void RuntimeTreeEnsembleCommonP<NTYPE>::compute_gil_free_array_structure(
929934
unsigned char* p_has_score = &local_has_scores[i * n_targets_or_classes_];
930935
NTYPE* pp_score = p_score + size_obs;
931936
unsigned char* pp_has_score = p_has_score + size_obs;
932-
for (size_t j = 1; j < nth; ++j, pp_score += size_obs, pp_has_score += size_obs) {
937+
for (size_t j = 1; j < (size_t)nth; ++j, pp_score += size_obs, pp_has_score += size_obs) {
933938
agg.MergePrediction(
934939
n_targets_or_classes_,
935940
p_score, p_has_score, pp_score, pp_has_score);

0 commit comments

Comments
 (0)