MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CopyAttrsQuantizedConv2D

Method CopyAttrsQuantizedConv2D

tensorflow/core/graph/mkl_layout_pass.cc:2803–2844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2801}
2802
2803void MklLayoutRewritePass::CopyAttrsQuantizedConv2D(const Node* orig_node,
2804 NodeBuilder* nb,
2805 bool change_format) {
2806 DataType Tinput, Tfilter, out_type;
2807 string padding;
2808 string data_format("NHWC");
2809 std::vector<int32> strides, dilations, padding_list;
2810 bool has_padding_list = HasNodeAttr(orig_node->def(), "padding_list");
2811
2812 // Get all attributes from old node.
2813 TF_CHECK_OK(GetNodeAttr(orig_node->def(), "Tinput", &Tinput));
2814 TF_CHECK_OK(GetNodeAttr(orig_node->def(), "Tfilter", &Tfilter));
2815 TF_CHECK_OK(GetNodeAttr(orig_node->def(), "out_type", &out_type));
2816 TF_CHECK_OK(GetNodeAttr(orig_node->def(), "padding", &padding));
2817 TF_CHECK_OK(GetNodeAttr(orig_node->def(), "strides", &strides));
2818 TF_CHECK_OK(GetNodeAttr(orig_node->def(), "dilations", &dilations));
2819 if (has_padding_list) {
2820 TF_CHECK_OK(GetNodeAttr(orig_node->def(), "padding_list", &padding_list));
2821 }
2822
2823 Node* filter_node = nullptr;
2824 TF_CHECK_OK(orig_node->input_node(1, &filter_node));
2825
2826 // Add attributes to new node.
2827 nb->Attr("Tinput", Tinput);
2828 nb->Attr("Tfilter", Tfilter);
2829 nb->Attr("out_type", out_type);
2830 nb->Attr("padding", padding);
2831 nb->Attr("is_filter_const", filter_node->IsConstant());
2832 nb->Attr("strides", strides);
2833 nb->Attr("dilations", dilations);
2834 nb->Attr("T", out_type); // added "T" for facilitating MklToTf conversion.
2835 nb->Attr("data_format", data_format);
2836 if (has_padding_list) {
2837 nb->Attr("padding_list", padding_list);
2838 }
2839
2840 // Requantization attr Tbias.
2841 DataType Tbias;
2842 Status bias_status = GetNodeAttr(orig_node->def(), "Tbias", &Tbias);
2843 if (bias_status.ToString() == "OK") nb->Attr("Tbias", Tbias);
2844}
2845
2846void MklLayoutRewritePass::CopyAttrsQuantizedMatMulWithBiasAndDequantize(
2847 const Node* orig_node, NodeBuilder* nb, bool change_format) {

Callers

nothing calls this directly

Calls 5

input_nodeMethod · 0.80
GetNodeAttrFunction · 0.50
AttrMethod · 0.45
IsConstantMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected