From: T.J. Mercier Date: Fri, 15 Nov 2019 19:15:12 +0000 (-0800) Subject: Add check to ensure input file was successfully opened in NNVM deploy code demo ... X-Git-Tag: upstream/0.7.0~1635 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da23619a8cc05ce253c0bf8955a5549c16322468;p=platform%2Fupstream%2Ftvm.git Add check to ensure input file was successfully opened in NNVM deploy code demo (#4315) --- diff --git a/docs/deploy/nnvm.md b/docs/deploy/nnvm.md index 4040de3..6509122 100644 --- a/docs/deploy/nnvm.md +++ b/docs/deploy/nnvm.md @@ -59,9 +59,11 @@ An example in c++. #include #include +#include #include #include -#include +#include +#include int main() { @@ -97,7 +99,9 @@ int main() int64_t in_shape[4] = {1, 3, 224, 224}; TVMArrayAlloc(in_shape, in_ndim, dtype_code, dtype_bits, dtype_lanes, device_type, device_id, &x); // load image data saved in binary - std::ifstream data_fin("cat.bin", std::ios::binary); + const std::string data_filename = "cat.bin"; + std::ifstream data_fin(data_filename, std::ios::binary); + if(!data_fin) throw std::runtime_error("Could not open: " + data_filename); data_fin.read(static_cast(x->data), 3 * 224 * 224 * 4); // get the function from the module(set input data)