Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check to ensure input file was successfully opened in NNVM deploy… #4315

Merged
merged 1 commit into from
Nov 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/deploy/nnvm.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ An example in c++.
#include <tvm/runtime/registry.h>
#include <tvm/runtime/packed_func.h>

#include <algorithm>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <stdexcept>
#include <string>

int main()
{
Expand Down Expand Up @@ -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<char*>(x->data), 3 * 224 * 224 * 4);

// get the function from the module(set input data)
Expand Down