ONE - On-device Neural Engine
Loading...
Searching...
No Matches
DecodeCommand.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "DecodeCommand.hpp"
18#include "Support.hpp"
19
20#include <onnx/onnx.pb.h>
21
22#include <google/protobuf/io/coded_stream.h>
23#include <google/protobuf/io/zero_copy_stream_impl.h>
24#include <google/protobuf/text_format.h>
25
26int DecodeCommand::run(int argc, const char *const *argv) const
27{
28 onnx::ModelProto model;
29
30 Cmdline cmdline(argc, argv);
31
32 auto ui = make_ui(cmdline);
33
34 google::protobuf::io::IstreamInputStream is{ui->in()};
35 google::protobuf::io::CodedInputStream coded_is{&is};
36
37 if (!model.ParseFromCodedStream(&coded_is))
38 {
39 std::cerr << "ERROR: Failed to parse ONNX model" << std::endl;
40 return 255;
41 }
42
43 google::protobuf::io::OstreamOutputStream os{ui->out()};
44 google::protobuf::TextFormat::Print(model, &os);
45
46 return 0;
47}
Definition View.h:23
std::unique_ptr< UI > make_ui(const Cmdline &cmdargs)
Definition Support.cpp:61
int run(int argc, const char *const *argv) const override