Skip to content

Commit 896a070

Browse files
author
Li, Guizi
authored
code clean (#27)
1 parent 8287386 commit 896a070

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tensorflow/core/grappler/optimizers/remapper.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,9 @@ bool FindContractionWithBiasAddAndAdd(const RemapperContext& ctx,
707707
bool SharedInputWithMatMul(const RemapperContext& ctx, int node_index,
708708
int node_dz) {
709709
const auto* node_view = ctx.graph_view.GetNode(node_index);
710+
if (node_view == nullptr) return false;
710711
const auto* shared_input = node_view->GetRegularFanin(0).node_view();
712+
if (shared_input == nullptr) return false;
711713
if (shared_input->node_index() == node_dz) {
712714
shared_input = node_view->GetRegularFanin(1).node_view();
713715
}
@@ -733,6 +735,7 @@ bool SharedInputWithMatMul(const RemapperContext& ctx, int node_index,
733735
bool FindContractionWithBiasAddGrad(const RemapperContext& ctx, int node_index,
734736
ContractionWithBiasAddGrad* matched) {
735737
const auto* node_view = ctx.graph_view.GetNode(node_index);
738+
if (node_view == nullptr) return false;
736739
// TODO(lyandy): Forward controls for patterns with control dependencies.
737740
if (HasControlFaninOrFanout(*node_view)) return false;
738741

@@ -764,6 +767,7 @@ bool FindContractionWithBiasAddGrad(const RemapperContext& ctx, int node_index,
764767
// the forward input with index 0.
765768

766769
const auto* dz = node_view->GetRegularFanin(0).node_view();
770+
if (dz == nullptr) return false;
767771
// The node index for MatMulGradFilter if found.
768772
int matmul_grad_filter_idx = -1;
769773

@@ -1838,6 +1842,7 @@ Status AddBatchNormNodes(RemapperContext* ctx, const FusedBatchNorm& matched) {
18381842
#ifdef INTEL_MKL
18391843
bool IsConv2DWithAdd(const RemapperContext& ctx, int node_index) {
18401844
const auto* node_view = ctx.graph_view.GetNode(node_index);
1845+
if (node_view == nullptr) return false;
18411846
const auto* node_def = node_view->node();
18421847

18431848
// Candidate for Conv2D + Add or Conv2D + BiasAdd + Add fusion.

0 commit comments

Comments
 (0)