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

Function LRNGrad

tensorflow/core/kernels/mkl_lrn_op_test.cc:101–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100template <typename T>
101static Graph* LRNGrad(const string& kind, int DR, const TensorShape& in_shape,
102 float BIAS = 1.0f, float ALPHA = 0.1f, float BETA = 2.0f) {
103 Graph* g = new Graph(OpRegistry::Global());
104 DataType type = DataTypeToEnum<T>::v();
105
106 const bool isDefault = (kind == "Default");
107 string op_name = isDefault ? "LRNGrad" : "_MklLRNGrad";
108
109 Tensor inGrad(type, in_shape);
110 inGrad.flat<T>().setRandom();
111
112 Tensor in0(type, in_shape);
113 in0.flat<T>().setRandom();
114
115 Tensor out(DT_FLOAT, in_shape);
116
117 Node* input_inGrad = test::graph::Constant(g, inGrad);
118 Node* input_in0 = test::graph::Constant(g, in0);
119 Node* output = test::graph::Constant(g, out);
120
121 Node* not_mkl_shape =
122 test::graph::Constant(g, GetMklMetaTensor(), "not_mkl");
123
124 auto nodeBuilder = NodeBuilder(g->NewName("n"), op_name)
125 .Input(input_inGrad)
126 .Input(input_in0)
127 .Input(output)
128 .Attr("depth_radius", DR)
129 .Attr("bias", BIAS)
130 .Attr("alpha", ALPHA)
131 .Attr("beta", BETA);
132
133 isDefault ? nodeBuilder : nodeBuilder.Input(not_mkl_shape)
134 .Input(not_mkl_shape)
135 .Input(not_mkl_shape)
136 .Input(not_mkl_shape)
137 .Input(not_mkl_shape)
138 .Attr("_kernel", "MklLayoutDependentOp");
139
140 TF_CHECK_OK(nodeBuilder.Finalize(g, nullptr));
141
142 return g;
143}
144
145#define BM_LRNGrad_Base(kind, DR, in_shape, name, T, DEVICE, NTH) \
146 static void BM_LRNGrad##_##kind##_##DR##name##_##T##_##DEVICE##_##NTH( \

Callers 1

LRNGradHelperFunction · 0.50

Calls 7

GetMklMetaTensorFunction · 0.85
ConstantFunction · 0.70
NodeBuilderClass · 0.50
AttrMethod · 0.45
InputMethod · 0.45
NewNameMethod · 0.45
FinalizeMethod · 0.45

Tested by

no test coverage detected