| 769 | } |
| 770 | |
| 771 | NodeID GraphBuilder::add_scale_layer(Graph &g, |
| 772 | const NodeParams ¶ms, |
| 773 | NodeIdxPair input, |
| 774 | ITensorAccessorUPtr mul_accessor, |
| 775 | ITensorAccessorUPtr add_accessor) |
| 776 | { |
| 777 | check_nodeidx_pair(input, g); |
| 778 | |
| 779 | // Get input tensor descriptor |
| 780 | const TensorDescriptor input_tensor_desc = get_tensor_descriptor(g, g.node(input.node_id)->outputs()[0]); |
| 781 | const DataLayout input_data_layout = input_tensor_desc.layout; |
| 782 | |
| 783 | // Create mul node |
| 784 | TensorDescriptor mul_desc = input_tensor_desc; |
| 785 | const size_t C = input_tensor_desc.shape[get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL)]; |
| 786 | mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::WIDTH), 1); |
| 787 | mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::HEIGHT), 1); |
| 788 | mul_desc.shape.set(get_dimension_idx(input_data_layout, DataLayoutDimension::CHANNEL), C); |
| 789 | NodeID mul_const_nid = add_const_node_with_name(g, params, "Mul", mul_desc, std::move(mul_accessor)); |
| 790 | NodeIdxPair mul_const_nidxp = {mul_const_nid, 0}; |
| 791 | |
| 792 | // Create add node |
| 793 | TensorDescriptor add_desc = mul_desc; |
| 794 | NodeID add_const_nid = add_const_node_with_name(g, params, "Add", add_desc, std::move(add_accessor)); |
| 795 | NodeIdxPair add_const_nidxp = {add_const_nid, 0}; |
| 796 | |
| 797 | // Create node and connect |
| 798 | NodeID mul_node = GraphBuilder::add_elementwise_node(g, params, input, mul_const_nidxp, EltwiseOperation::Mul); |
| 799 | NodeIdxPair mulnode_nidxp = {mul_node, 0}; |
| 800 | NodeID add_node = |
| 801 | GraphBuilder::add_elementwise_node(g, params, mulnode_nidxp, add_const_nidxp, EltwiseOperation::Add); |
| 802 | |
| 803 | return add_node; |
| 804 | } |
| 805 | |
| 806 | NodeID GraphBuilder::add_softmax_node(Graph &g, NodeParams params, NodeIdxPair input, float beta) |
| 807 | { |
nothing calls this directly
no test coverage detected