Skip to content

Commit

Permalink
Add an option to disable shape and type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
VivekPanyam committed May 28, 2020
1 parent 11ba3c2 commit e0c7870
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions source/neuropod/backends/neuropod_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,23 @@ std::unique_ptr<NeuropodValueMap> NeuropodBackend::infer(const NeuropodValueMap
"`load_model_at_construction` was set to false and `load_model()` was not explicitly called");
}

// Validate inputs
validate_tensors_against_specs(inputs, get_inputs(), "input spec");
if (!options_.disable_shape_and_type_checking)
{
// Validate inputs
validate_tensors_against_specs(inputs, get_inputs(), "input spec");
}

// Seal the inputs
auto sealed = sealer_->seal(inputs);

// Run inference
auto out = infer_internal(sealed, requested_outputs);

// Validate outputs
validate_tensors_against_specs(*out, get_outputs(), "output spec");
if (!options_.disable_shape_and_type_checking)
{
// Validate outputs
validate_tensors_against_specs(*out, get_outputs(), "output spec");
}

return out;
}
Expand Down
3 changes: 3 additions & 0 deletions source/neuropod/options.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ struct RuntimeOptions
// immediately loading the model. If this is set to `false`, the model will
// not be loaded until the `load_model` method is called on the Neuropod.
bool load_model_at_construction = true;

// Whether or not to disable shape and type checking when running inference
bool disable_shape_and_type_checking = false;
};

} // namespace neuropod

0 comments on commit e0c7870

Please # to comment.