#include <loco/Service/ShapeInference.h>
+#include <oops/InternalExn.h>
+
#include <cassert>
namespace
// each dimension of x and y should be same or one must be 1 if different
if (!((x_dim == y_dim) || (x_dim == 1 || y_dim == 1)))
- throw std::runtime_error("Cannot produce expand_dimension of two shapes");
+ {
+ // TODO may need to refine message
+ INTERNAL_EXN("ShapeInference: Input shapes don't match");
+ }
output_shape.dim(axis) = std::max(x_dim, y_dim);
}
else
{
// TODO support for other data_layout if needed
- throw std::runtime_error("as_tensor_shape: only supports NHWC or NCHW");
+ INTERNAL_EXN_V("ShapeInference: Unknown data_format", data_layout);
}
return tensor_shape;
// only convert from tensor to feature
if (nodeshape.domain() != loco::Domain::Tensor)
{
- throw std::runtime_error("as_feature_shape: domain is not tensor");
+ INTERNAL_EXN("ShapeInference: Invalid shape information");
}
loco::TensorShape tensor_shape = nodeshape.as<loco::TensorShape>();
if (tensor_shape.rank() != 4)
{
- throw std::runtime_error("as_feature_shape: rank is not 4");
+ INTERNAL_EXN("ShapeInference: Rank is not 4");
}
if (data_layout == "NHWC")
else
{
// TODO support for other data_layout if needed
- throw std::runtime_error("as_feature_shape: only supports NHWC or NCHW");
+ INTERNAL_EXN_V("ShapeInference: Unknown data_format", data_layout);
}
return feature_shape;
else if (tf_layout_str == "NCHW")
return DataLayout::NCHW;
else
- throw std::runtime_error("unknown data layout");
+ /// @note data layout tag in TensorFlow is 'data_format'
+ INTERNAL_EXN_V("ShapeInference: Unknown data_format", tf_layout_str);
}
} // namespace
stride.vertical(strides[2]);
stride.horizontal(strides[3]);
}
+ else
+ {
+ // TODO add more datalayout supports if needed
+ INTERNAL_EXN("ShapeInference: Unknown data_format");
+ }
return stride;
}
window.vertical(ksize[2]);
window.horizontal(ksize[3]);
}
+ else
+ {
+ // TODO add more datalayout supports if needed
+ INTERNAL_EXN("ShapeInference: Unknown data_format");
+ }
return window;
}
else
{
// TODO add more datalayout supports if needed
- assert(false);
+ INTERNAL_EXN_V("ShapeInference: Unknown data_format", datalayout);
}
return window;