From bacce56fbbf99375bda6e772501e1c77e20695b6 Mon Sep 17 00:00:00 2001 From: okdshin Date: Tue, 27 Aug 2019 03:08:14 +0000 Subject: [PATCH] replace assert with CHECK --- menoh/menoh_chainer_compiler.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/menoh/menoh_chainer_compiler.cpp b/menoh/menoh_chainer_compiler.cpp index 714ab7df..b7fffeda 100644 --- a/menoh/menoh_chainer_compiler.cpp +++ b/menoh/menoh_chainer_compiler.cpp @@ -178,7 +178,7 @@ onnx::TensorProto::DataType menoh_dtype_to_xtensor_dtype(menoh_dtype mdtype) { } else if (mdtype == menoh_dtype_bool) { return onnx::TensorProto::BOOL; } else { - assert(!"Not Implemeneted"); + CHECK(false) << "Not Implemeneted menoh_dtype: " << mdtype; } return onnx::TensorProto::UNDEFINED; } @@ -602,7 +602,7 @@ menoh_error_code menoh_build_model( auto xgraph = *(builder->xgraph); // Set initializer - assert(xgraph.initializer().empty()); + CHECK(xgraph.initializer().empty()); for (onnx::TensorProto const& xtensor : model_data->xgraph.initializer()) { *(xgraph.add_initializer()) = xtensor; } @@ -626,7 +626,7 @@ menoh_error_code menoh_build_model( for (const chainer_compiler::Value* input : graph.input_values()) { if (!input->initializer()) { // user input is input which doesn't have initializer auto p = builder->input_profile_table.find(input->name()); - assert(p != builder->input_profile_table.end()); + CHECK(p != builder->input_profile_table.end()) << input->name() << " is not found in input_profile_table"; void* datap = nullptr; auto found = builder->external_buffer_handle_table.find(input->name()); if (found != builder->external_buffer_handle_table.end()) { @@ -652,7 +652,7 @@ menoh_error_code menoh_build_model( datap = found->second; } else { auto p = builder->output_profile_table.find(output->name()); - assert(p != builder->output_profile_table.end()); + CHECK(p != builder->output_profile_table.end()) << output->name() << " is not found in output_profile_table"; auto data = allocate_buffer(p->second); buffer_holder.push_back(data); datap = data.get(); @@ -755,13 +755,14 @@ menoh_error_code menoh_model_run(menoh_model_handle model) { auto outputs = model->chxvm->Run(model->inputs, model->chxvm_options); for (auto output : outputs) { auto found = model->outputs.find(output.first); - assert(found != model->outputs.end() && "output buffer not found"); + CHECK(found != model->outputs.end()) << "output buffer for " << output.first << " is not found"; auto const& array = chainerx::AsContiguous(output.second->GetArray()); auto const& shape = array.shape(); auto bytesize = shape.GetTotalSize() * chainerx::GetItemSize(array.dtype()); - assert(model->variable_profiles.find(output.first) != model->variable_profiles.end()); - assert(bytesize == menoh_impl::total_size_in_bytes(variable_profiles.find(output.first)->second) && - "allocated output buffer size is not same to cc's output buffer size"); + CHECK(model->variable_profiles.find(output.first) != model->variable_profiles.end()) + << output.first << " is not found in variable_profiles"; + CHECK_EQ(bytesize, menoh_impl::total_size_in_bytes(model->variable_profiles.find(output.first)->second)) + << "allocated output buffer size is not equal to cc's output buffer size"; std::copy( static_cast(array.raw_data()), static_cast(array.raw_data()) + bytesize,