target_link_libraries(moco_tf_frontend PRIVATE plier_tf)
target_link_libraries(moco_tf_frontend PRIVATE locoex_customop)
target_link_libraries(moco_tf_frontend PRIVATE logo)
+target_link_libraries(moco_tf_frontend PRIVATE oops)
install(TARGETS moco_tf_frontend DESTINATION lib)
if(NOT ENABLE_TEST)
require("plier-tf")
require("locoex-customop")
require("logo")
+require("oops")
#include <moco/Names.h>
#include <moco/Log.h>
+#include <oops/UserExn.h>
+
namespace
{
break;
}
default:
- throw std::runtime_error("NYI for this DataType");
+ throw oops::UserExn("Const has unsupported data type", node->name());
}
// update graph
#include <moco/Log.h>
#include <plier/tf/Convert.h>
+#include <oops/UserExn.h>
#include <cassert>
// has wildcard dimension, i.e. dynamic reshape
return false;
}
- assert(shape_dim >= 1 && "Unknown behavior: New shape of Reshape has invalid dimension");
+ if (!(shape_dim >= 1))
+ {
+ throw oops::UserExn("New shape of Reshape has invalid dimension");
+ }
}
return true;
}
{
// Only support fixed reshape
// TODO support dynamic reshape
- assert(is_fixed_shape_input(tfconst_shape_input));
+ if (!(is_fixed_shape_input(tfconst_shape_input)))
+ {
+ throw oops::UserExn("Supports only fixed reshape", node->name());
+ }
auto rank = tfconst_shape_input->dim(0).value();
fixed_reshape->rank(rank);
else if (constgen_shape_input)
{
// ditto
- assert(is_fixed_shape_input(constgen_shape_input));
+ if (!(is_fixed_shape_input(constgen_shape_input)))
+ {
+ throw oops::UserExn("Supports only fixed reshape", node->name());
+ }
auto rank = constgen_shape_input->dim(0).value();
fixed_reshape->rank(rank);
else
{
// TODO support dynamic reshape from not const node
- throw std::runtime_error("ReshapeCanonicalizer: only support const node as input shape");
+ throw oops::UserExn("Supports only const node as input shape", node->name());
}
// replace
#include <cwrap/Fildes.h>
#include <stdex/Memory.h>
+#include <oops/UserExn.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
if (fildes.get() < 0)
{
- throw std::runtime_error{"Error: " + path + " not found"};
+ throw oops::UserExn("File not found", path);
}
bool result = (type == moco::tf::Frontend::FileType::Text) ? load_text(fildes, graph_def)
: load_binary(fildes, graph_def);
if (!result)
{
- throw std::runtime_error{"Error: Failed to parse prototxt " + path};
+ throw oops::UserExn("Failed to parse prototxt file", path);
}
}
: load_binary(stream, graph_def);
if (!result)
{
- throw std::runtime_error{"Error: Failed to parse prototxt from stream"};
+ throw oops::UserExn("Failed to parse prototxt from stream");
}
}
#include <moco/tf/Frontend.h>
#include <loco.h>
#include <stdex/Memory.h>
+#include <oops/UserExn.h>
#include <vector>
#include <cassert>
// TODO define more types
else
{
- throw std::runtime_error("not supported attribute type");
+ throw oops::UserExn("Unsupported attribute type", tf_node.name());
}
}
}
#include <pepper/str.h>
#include <locoex/Service/COpFormattedGraph.h>
+#include <oops/InternalExn.h>
#include <sstream>
ss << node->size<loco::DataType::FLOAT32>();
break;
default:
- throw std::runtime_error("NYI for this DataType");
+ INTERNAL_EXN_V("Unsupported data type", node->name());
}
s.args().append("size", ss.str());
s.state(locop::NodeSummary::State::PartiallyKnown);