tensorflow/core/common_runtime/mkl_tfconversion_pass_test.cc
// MklConv2D followed by MklToTf op followed by Non-Mkl layer.
// C=MklConv2D(A,M,B,N); D=MklToTf(C:0, C:1) F=Sub(D,E) (for interleaved)
// C=MklConv2D(A,B,M,N); D=MklToTf(C:0, C:2) F=Sub(D,E) (for contiguous)
// MklToTf node should not be inserted again.
MklConv2D followed by MklToTf op followed by Non-Mkl layer.
MklConv2D followed by MklToTf op followed by Non - Mkl layer .
TEST_F(MklToTfConversionPass, Negative_DoubleInsert) {
  if (kTensorOrdering == MklTfTensorOrdering::TENSORS_INTERLEAVED) {
    InitGraph(
        "node { name: 'A' op: 'Float_Input'}"
        "node { name: 'M' op: '_Mkl_Input'}"
        "node { name: 'B' op: 'Float_Input'}"
        "node { name: 'N' op: '_Mkl_Input'}"
        "node { name: 'C' op: '_MklConv2D'"
        " attr { key: 'T'                value { type: DT_FLOAT } }"
        " attr { key: 'data_format'      value { s: 'NCHW' } }"
        " attr { key: 'use_cudnn_on_gpu' value { b: false } }"
        " attr { key: 'strides'          value { list: {i: 1, i:1, i:1, i:1} } "
        "}"
        " attr { key: 'padding'          value { s: 'SAME' } }"
        " input: ['A', 'M', 'B', 'N']}"
        "node { name: 'D' op: '_MklToTf'"
        " attr { key: 'T'                value { type: DT_FLOAT } }"
        " attr { key: 'data_format'      value { s: 'NCHW' } }"
        " input: ['C:0', 'C:1']}"
        "node { name: 'E' op: 'Float_Input'}"
        "node { name: 'F' op: 'Sub'"
        " attr {key: 'T'                 value { type: DT_FLOAT } }"
        " input: ['D', 'E']}");
    EXPECT_EQ(DoRunMklToTfConversionPass(),
              "A(Float_Input);B(Float_Input);C(_MklConv2D);D(_MklToTf);E(Float_"
              "Input);"
              "F(Sub);M(_Mkl_Input);N(_Mkl_Input)|"
              "A->C;B->C:2;C->D;C:1->D:1;D->F;E->F:1;M->C:1;N->C:3");
  } else {
    CHECK_EQ(kTensorOrdering, MklTfTensorOrdering::TENSORS_CONTIGUOUS);
    InitGraph(
        "node { name: 'A' op: 'Float_Input'}"
        "node { name: 'B' op: 'Float_Input'}"
        "node { name: 'M' op: '_Mkl_Input'}"
        "node { name: 'N' op: '_Mkl_Input'}"
        "node { name: 'C' op: '_MklConv2D'"
        " attr { key: 'T'                value { type: DT_FLOAT } }"
        " attr { key: 'data_format'      value { s: 'NCHW' } }"
        " attr { key: 'use_cudnn_on_gpu' value { b: false } }"
        " attr { key: 'strides'          value { list: {i: 1, i:1, i:1, i:1} } "
        "}"
        " attr { key: 'padding'          value { s: 'SAME' } }"
        " input: ['A', 'B', 'M', 'N']}"
        "node { name: 'D' op: '_MklToTf'"
        " attr { key: 'T'                value { type: DT_FLOAT } }"
        " attr { key: 'data_format'      value { s: 'NCHW' } }"
        " input: ['C:0', 'C:2']}"
        "node { name: 'E' op: 'Float_Input'}"
        "node { name: 'F' op: 'Sub'"
        " attr {key: 'T'                 value { type: DT_FLOAT } }"
        " input: ['D', 'E']}");
    EXPECT_EQ(DoRunMklToTfConversionPass(),
              "A(Float_Input);B(Float_Input);C(_MklConv2D);D(_MklToTf);E(Float_"
              "Input);"
              "F(Sub);M(_Mkl_Input);N(_Mkl_Input)|"
              "A->C;B->C:1;C->D;C:2->D:1;D->F;E->F:1;M->C:2;N->C:3");
  }
}
TEST_F ( MklToTfConversionPass , Negative_DoubleInsert ) { if ( kTensorOrdering == MklTfTensorOrdering :: TENSORS_INTERLEAVED ) { InitGraph ( " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " ) ; EXPECT_EQ ( DoRunMklToTfConversionPass ( ) , " " " " " " " " ) ; } else { CHECK_EQ ( kTensorOrdering , MklTfTensorOrdering :: TENSORS_CONTIGUOUS ) ; InitGraph ( " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " " ) ; EXPECT_EQ ( DoRunMklToTfConversionPass ( ) , " " " " " " " " ) ; } }
MklConv2D followed by MklToTf op followed by Non-Mkl layer.
MklConv2D followed by MklToTf op followed by Non - Mkl layer .