This will update to use correct input accessor for MaxPool and FusedBatchNorm node and related variables
Signed-off-by: SaeHie Park <saehie.park@samsung.com>
set_feature_dec(feature_dec, data_layout);
// paddata to pad
- auto value_shape = moco::tf::node_shape(node->value());
- assert(value_shape.domain() != loco::Domain::Unknown);
+ auto input_shape = moco::tf::node_shape(node->input());
+ assert(input_shape.domain() != loco::Domain::Unknown);
auto node_stride = moco::tf::stride_of(node->strides(), node->data_layout());
auto node_window = moco::tf::window_of(node->ksize(), node->data_layout());
infer_padding2d.stride(node_stride);
infer_padding2d.window(node_window);
- auto input_feature_shape = moco::tf::as_feature_shape(value_shape, node->data_layout());
+ auto input_feature_shape = moco::tf::as_feature_shape(input_shape, node->data_layout());
auto input_plane_shape = moco::tf::make_plane_shape(input_feature_shape);
*maxPool2d_node->pad() = infer_padding2d(input_plane_shape);
<< maxPool2d_node->pad()->right() << std::endl;
// update graph
- auto node_A = node->value();
+ auto node_A = node->input();
// update connections
feature_enc->input(node_A);
int num_inputs = _names.size();
assert(num_inputs == 5);
- _node->input(tensor_names->node(_names[0]));
- _node->gamma(tensor_names->node(_names[1]));
- _node->beta(tensor_names->node(_names[2]));
+ _node->x(tensor_names->node(_names[0]));
+ _node->scale(tensor_names->node(_names[1]));
+ _node->offset(tensor_names->node(_names[2]));
_node->mean(tensor_names->node(_names[3]));
_node->variance(tensor_names->node(_names[4]));
}
moco::tf::TFFusedBatchNorm *fbn_node =
moco::tf::test::find_first_node_bytype<moco::tf::TFFusedBatchNorm>(graph.get());
- ASSERT_NE(fbn_node->input(), nullptr);
- ASSERT_NE(fbn_node->gamma(), nullptr);
- ASSERT_NE(fbn_node->beta(), nullptr);
+ ASSERT_NE(fbn_node->x(), nullptr);
+ ASSERT_NE(fbn_node->scale(), nullptr);
+ ASSERT_NE(fbn_node->offset(), nullptr);
ASSERT_NE(fbn_node->mean(), nullptr);
ASSERT_NE(fbn_node->variance(), nullptr);
ASSERT_EQ(fbn_node->epsilon(), 0.001f);
{
public:
TFMaxPoolGraphUpdate(moco::tf::TFMaxPool *node, const TensorName &name)
- : _maxpool_node(node), _value_name(name)
+ : _maxpool_node(node), _input_name(name)
{
}
private:
moco::tf::TFMaxPool *_maxpool_node;
- const TensorName _value_name;
+ const TensorName _input_name;
};
void TFMaxPoolGraphUpdate::input(const SymbolTable *node_table) const
{
- loco::Node *value_node = node_table->node(_value_name);
- _maxpool_node->value(value_node);
+ loco::Node *input_node = node_table->node(_input_name);
+ _maxpool_node->input(input_node);
}
} // namespace
moco::tf::test::find_first_node_bytype<moco::tf::TFMaxPool>(graph.get());
ASSERT_NE(maxpool_node, nullptr);
- loco::Node *previous_node = maxpool_node->value();
+ loco::Node *previous_node = maxpool_node->input();
auto following_nodes = loco::succs(maxpool_node);
ASSERT_EQ(following_nodes.size(), 1);
loco::Node *following_node = *following_nodes.begin();
bool TFNodeSummaryBuilder::summary(const TFFusedBatchNorm *node, locop::NodeSummary &s) const
{
- s.args().append("input", tbl()->lookup(node->input()));
- s.args().append("gamma", tbl()->lookup(node->gamma()));
- s.args().append("beta", tbl()->lookup(node->beta()));
+ s.args().append("x", tbl()->lookup(node->x()));
+ s.args().append("scale", tbl()->lookup(node->scale()));
+ s.args().append("offset", tbl()->lookup(node->offset()));
s.args().append("mean", tbl()->lookup(node->mean()));
s.args().append("variance", tbl()->lookup(node->variance()));
s.args().append("epsilon", pepper::str(node->epsilon()));
bool TFNodeSummaryBuilder::summary(const TFMaxPool *node, locop::NodeSummary &s) const
{
- s.args().append("value", tbl()->lookup(node->value()));
+ s.args().append("input", tbl()->lookup(node->input()));
s.args().append("ksize", pepper::str(node->ksize()));
s.args().append("strides", pepper::str(node->strides()));
s.args().append("padding", node->padding());
{
LOGGER(lfbn);
- auto tffbn_input = node->input();
- if (tffbn_input == nullptr)
+ auto tffbn_x = node->x();
+ if (tffbn_x == nullptr)
{
// This node is already converted
return false;
}
- auto tffbn_gamma = dynamic_cast<moco::tf::TFConst *>(node->gamma());
- auto tffbn_beta = dynamic_cast<moco::tf::TFConst *>(node->beta());
+ auto tffbn_scale = dynamic_cast<moco::tf::TFConst *>(node->scale());
+ auto tffbn_offset = dynamic_cast<moco::tf::TFConst *>(node->offset());
auto tffbn_mean = dynamic_cast<moco::tf::TFConst *>(node->mean());
auto tffbn_variance = dynamic_cast<moco::tf::TFConst *>(node->variance());
// all should be const
- if (tffbn_gamma == nullptr || tffbn_beta == nullptr || tffbn_mean == nullptr ||
+ if (tffbn_scale == nullptr || tffbn_offset == nullptr || tffbn_mean == nullptr ||
tffbn_variance == nullptr)
{
INFO(lfbn) << "TFFBN resolve_to_muladd: One of constant input node is not a constant"
<< std::endl;
return false;
}
- assert(tffbn_gamma->dtype() == loco::DataType::FLOAT32);
- assert(tffbn_beta->dtype() == loco::DataType::FLOAT32);
+ assert(tffbn_scale->dtype() == loco::DataType::FLOAT32);
+ assert(tffbn_offset->dtype() == loco::DataType::FLOAT32);
assert(tffbn_mean->dtype() == loco::DataType::FLOAT32);
assert(tffbn_variance->dtype() == loco::DataType::FLOAT32);
// check all const shape are the same
- if (!is_same_shape(tffbn_gamma, tffbn_beta) || !is_same_shape(tffbn_gamma, tffbn_mean) ||
- !is_same_shape(tffbn_gamma, tffbn_variance))
+ if (!is_same_shape(tffbn_scale, tffbn_offset) || !is_same_shape(tffbn_scale, tffbn_mean) ||
+ !is_same_shape(tffbn_scale, tffbn_variance))
{
INFO(lfbn) << "TFFBN resolve_to_muladd: Shape of constant are not same" << std::endl;
return false;
auto tffbn_epsilon = node->epsilon();
INFO(lfbn) << "TFFBN tffbn_epsilon = " << tffbn_epsilon << std::endl;
- auto const_num_elements = tffbn_gamma->size<loco::DataType::FLOAT32>();
+ auto const_num_elements = tffbn_scale->size<loco::DataType::FLOAT32>();
INFO(lfbn) << "TFFBN const_num_elements = " << const_num_elements << std::endl;
// fbn_epsilon = %4:variance + fbn_epsilon_array
std::unique_ptr<float[]> fbn_mul{new float[const_num_elements]};
for (int32_t i = 0; i < const_num_elements; i++)
{
- fbn_mul.get()[i] = fbn_rsqrt.get()[i] * tffbn_gamma->at<loco::DataType::FLOAT32>(i);
+ fbn_mul.get()[i] = fbn_rsqrt.get()[i] * tffbn_scale->at<loco::DataType::FLOAT32>(i);
}
// fbn_offset = %2:beta : TODO remove this block and use %2:beta
std::unique_ptr<float[]> fbn_offset{new float[const_num_elements]};
for (int32_t i = 0; i < const_num_elements; i++)
{
- fbn_offset.get()[i] = tffbn_beta->at<loco::DataType::FLOAT32>(i);
+ fbn_offset.get()[i] = tffbn_offset->at<loco::DataType::FLOAT32>(i);
}
// fbn_mul_0_param = fbn_mul : remove this and use fbn_mul
*/
auto const_fbn_mul_0_param = graph->nodes()->create<moco::tf::TFConst>();
const_fbn_mul_0_param->dtype(loco::DataType::FLOAT32);
- copy_shape(tffbn_gamma, const_fbn_mul_0_param);
+ copy_shape(tffbn_scale, const_fbn_mul_0_param);
const_fbn_mul_0_param->size<loco::DataType::FLOAT32>(const_num_elements);
for (int32_t i = 0; i < const_num_elements; i++)
{
}
auto const_fbn_add_param = graph->nodes()->create<moco::tf::TFConst>();
const_fbn_add_param->dtype(loco::DataType::FLOAT32);
- copy_shape(tffbn_gamma, const_fbn_add_param);
+ copy_shape(tffbn_scale, const_fbn_add_param);
const_fbn_add_param->size<loco::DataType::FLOAT32>(const_num_elements);
for (int32_t i = 0; i < const_num_elements; i++)
{
* %22:fbn = TFAdd(%12:fbn_mul_0,%21:fbn_add_param)
*/
auto fbn_mul_0 = graph->nodes()->create<moco::tf::TFMul>();
- fbn_mul_0->x(tffbn_input);
+ fbn_mul_0->x(tffbn_x);
fbn_mul_0->y(const_fbn_mul_0_param);
auto fbn = graph->nodes()->create<moco::tf::TFAdd>();
// replace old node with new fbn
replace(node).with(fbn);
// unlink from graph
- node->input(nullptr);
- node->gamma(nullptr);
- node->beta(nullptr);
+ node->x(nullptr);
+ node->scale(nullptr);
+ node->offset(nullptr);
node->mean(nullptr);
node->variance(nullptr);