return shape;
}
+loco_tobe::BiasShape ShapeInferenceData::bias_shape(void) const
+{
+ assert(_domain == loco::Domain::Bias);
+
+ loco_tobe::BiasShape shape;
+
+ // Note: this may change when loco::BiasShape becomes available
+ shape = dim(0);
+
+ return shape;
+}
+
void ShapeInferenceData::feature_shape(const loco::FeatureShape &shape)
{
_domain = loco::Domain::Feature;
dim(3) = shape.depth();
}
+void ShapeInferenceData::bias_shape(const loco_tobe::BiasShape &shape)
+{
+ _domain = loco::Domain::Bias;
+
+ // Note: this may change when loco::BiasShape becomes available
+ rank(1);
+ dim(0) = shape;
+}
+
} // namespace tf
} // namespace moco
#include <cassert>
+namespace loco_tobe
+{
+
+// Temporary BiasShape that loco will provide in near future
+using BiasShape = loco::Dimension;
+
+} // namespace loco_tobe
+
namespace moco
{
namespace tf
loco::TensorShape tensor_shape(void) const;
loco::FeatureShape feature_shape(void) const;
loco::FilterShape filter_shape(void) const;
+ loco_tobe::BiasShape bias_shape(void) const;
void feature_shape(const loco::FeatureShape &shape);
void filter_shape(const loco::FilterShape &shape);
+ void bias_shape(const loco_tobe::BiasShape &shape);
private:
// TODO set default as Unknown, setting Tensor is to minimize change
ASSERT_EQ(shapedata.dim(2), 3);
ASSERT_EQ(shapedata.dim(3), 4);
}
+
+TEST(TensorFlowFrontend, shapeinferencedata_bias_set)
+{
+ // Note: this may change when loco::BiasShape becomes available
+
+ loco_tobe::BiasShape bias;
+
+ bias = 3;
+
+ moco::tf::ShapeInferenceData shapedata;
+
+ shapedata.bias_shape(bias);
+
+ ASSERT_EQ(shapedata.rank(), 1);
+ ASSERT_EQ(shapedata.dim(0), 3);
+}
+
+TEST(TensorFlowFrontend, shapeinferencedata_bias_get)
+{
+ // Note: this may change when loco::BiasShape becomes available
+
+ // This test is to check bias is stored in first dimension
+ // for normal case, we shouldn't access directly for bias
+ moco::tf::ShapeInferenceData shapedata;
+ loco_tobe::BiasShape dummy;
+
+ shapedata.bias_shape(dummy); // this is to set domain to bias
+
+ shapedata.rank(1);
+ shapedata.dim(0) = 3;
+
+ loco_tobe::BiasShape bias = shapedata.bias_shape();
+
+ ASSERT_EQ(bias, 3);
+}