From 66d0847b88e33ac5cc691c99daa89a2ec407be6d Mon Sep 17 00:00:00 2001 From: hong19860320 <9973393+hong19860320@users.noreply.github.com> Date: Mon, 10 Feb 2020 08:33:22 +0800 Subject: [PATCH] [XPU] Fix cast op bridge (#2817) --- lite/kernels/xpu/bridges/cast_op.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lite/kernels/xpu/bridges/cast_op.cc b/lite/kernels/xpu/bridges/cast_op.cc index 4b56abcd61..056822feb5 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 -- GitLab