diff --git a/lite/kernels/xpu/bridges/cast_op.cc b/lite/kernels/xpu/bridges/cast_op.cc index 4b56abcd61a1459391b7520cb5d0b4c17f901f40..056822feb54b3859afa49c75d9fc8ccb19a48520 100644 --- a/lite/kernels/xpu/bridges/cast_op.cc +++ b/lite/kernels/xpu/bridges/cast_op.cc @@ -78,7 +78,11 @@ int CastConverter(void* ctx, OpLite* op, KernelBase* kernel) { if (graph->Has(x_name)) { x_node = graph->Get(x_name); } else { - x_node = graph->Add(x_name, *x, in_ptype); + CHECK(x->precision() == in_ptype) + << "The data type of input tensor X should be " + << PrecisionToStr(in_ptype) << ", but received " + << PrecisionToStr(x->precision()); + x_node = graph->Add(x_name, *x); } // Cast node