This will revise Canonicalizers not to use ShapeInferenceData and use node_shape instead
Signed-off-by: SaeHie Park <saehie.park@samsung.com>
#include "Annotations/PadData.h"
#include "Annotations/StrideData.h"
-#include "Annotations/ShapeInferenceData.h"
#include "Annotations/WindowData.h"
#include "Dialect/TFDialect.h"
#include "LogHelper.h"
#include "Annotations/ConcatData.h"
-#include "Annotations/ShapeInferenceData.h"
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
#include "Dialect/TFNodeImpl.h"
+#include "Dialect/TFShapeInferenceHelper.h"
#include <moco/Log.h>
assert(concat_data != nullptr);
auto axis_value = concat_data->axis();
- auto shapedata = node->annot<ShapeInferenceData>();
- auto node_rank = shapedata->rank();
+ auto nodeshape = moco::tf::node_shape(node);
+ auto tensorshape = nodeshape.as<loco::TensorShape>();
+ auto node_rank = tensorshape.rank();
uint32_t axis_absolute = (axis_value >= 0) ? axis_value : (int32_t)node_rank + axis_value;
#include "DepthwiseConv2dNativeCanonicalizer.h"
#include "Annotations/PadData.h"
-#include "Annotations/ShapeInferenceData.h"
#include "Annotations/StrideData.h"
#include "Dialect/TFDialect.h"
#include "RsqrtCanonicalizer.h"
-#include "Annotations/ShapeInferenceData.h"
-
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
#include "Dialect/TFNodeImpl.h"
+#include "Dialect/TFShapeInferenceHelper.h"
#include <moco/Log.h>
{
template <typename T>
-void prepare_const_gen(loco::ConstGen *const_node, const moco::tf::ShapeInferenceData *shapedata,
- T value);
+void prepare_const_gen(loco::ConstGen *const_node, const loco::TensorShape &tensorshape, T value);
template <>
-void prepare_const_gen<float>(loco::ConstGen *const_node,
- const moco::tf::ShapeInferenceData *shapedata, float value)
+void prepare_const_gen<float>(loco::ConstGen *const_node, const loco::TensorShape &tensorshape,
+ float value)
{
LOGGER(l);
auto dtype = loco::DataType::FLOAT32;
const_node->dtype(dtype);
- auto rank = shapedata->rank();
+ auto rank = tensorshape.rank();
const_node->rank(rank);
for (uint32_t r = 0; r < rank; ++r)
{
- if (shapedata->dim(r).known())
- const_node->dim(r) = shapedata->dim(r);
+ if (tensorshape.dim(r).known())
+ const_node->dim(r) = tensorshape.dim(r);
else
throw std::runtime_error("Cannot handle unknown shape");
- assert(shapedata->dim(r).value() > 0);
+ assert(tensorshape.dim(r).value() > 0);
- const_num_elements *= shapedata->dim(r).value();
+ const_num_elements *= tensorshape.dim(r).value();
}
INFO(l) << "prepare_const_gen : Elements = " << const_num_elements;
* TFRsqrt is converted to 1 / EltwiseSqrt
*/
- auto rsqrt_shapedata = node->annot<moco::tf::ShapeInferenceData>();
- if (rsqrt_shapedata == nullptr)
+ auto nodeshape = moco::tf::node_shape(node);
+ if (nodeshape.domain() == loco::Domain::Unknown)
{
// We need this shape information
assert(false); // this shouldn't happen, let's add an alarm
return false;
}
+ auto tensorshape = nodeshape.as<loco::TensorShape>();
if (!loco::dtype_known(node))
{
switch (dtype)
{
case loco::DataType::FLOAT32:
- prepare_const_gen<float>(const_node, rsqrt_shapedata, 1.0f);
+ prepare_const_gen<float>(const_node, tensorshape, 1.0f);
break;
default:
#include "SoftmaxCanonicalizer.h"
-#include "Annotations/ShapeInferenceData.h"
-
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
#include "Dialect/TFNodeImpl.h"
+#include "Dialect/TFShapeInferenceHelper.h"
#include <moco/Log.h>
* In ---- TensorSoftmax ----- Out(s)
*/
- auto softmax_shape = node->annot<moco::tf::ShapeInferenceData>();
-
+ auto nodeshape = moco::tf::node_shape(node);
// Canonicalization into TensorSoftmax is valid when softmax has shape info
- assert(softmax_shape);
+ assert(nodeshape.domain() != loco::Domain::Unknown);
- auto softmax_tensor_shape = softmax_shape->tensor_shape();
+ auto softmax_tensor_shape = nodeshape.as<loco::TensorShape>();
// Create loco node to replace
auto softmax = graph->nodes()->create<loco::TensorSoftmax>();
#include "SqueezeCanonicalizer.h"
-#include "Annotations/ShapeInferenceData.h"
-
#include "Dialect/TFDialect.h"
#include "Dialect/TFNodes.h"
#include "Dialect/TFNodeVisitor.h"
#include "Dialect/TFNodeImpl.h"
+#include "Dialect/TFShapeInferenceHelper.h"
#include <moco/Log.h>
* In ---- FixedReshape ----- Out(s)
*/
- auto squeeze_shape = node->annot<moco::tf::ShapeInferenceData>();
+ auto nodeshape = moco::tf::node_shape(node);
// canonicalize into FixedReshape is valid when squeeze has shape info
// TODO Support general Squeeze case
- assert(squeeze_shape);
+ assert(nodeshape.domain() != loco::Domain::Unknown);
- auto squeeze_tensor_shape = squeeze_shape->tensor_shape();
+ auto squeeze_tensor_shape = nodeshape.as<loco::TensorShape>();
// Create loco node to replace
auto reshape = graph->nodes()->create<loco::FixedReshape>();