diff --git a/python/paddle_serving_client/__init__.py b/python/paddle_serving_client/__init__.py index b3687b7b5caef240035127fc0bfbce394acb8260..979a2f9e981cc287bbc877268a2c001c54f05f95 100644 --- a/python/paddle_serving_client/__init__.py +++ b/python/paddle_serving_client/__init__.py @@ -410,7 +410,11 @@ class GClient(object): if self.feed_types_[var.alias_name] == 'float': self.feed_types_[var.alias_name] = 'float32' if var.is_lod_tensor: - self.lod_tensor_set_.add(var.alias_name) + self.lod_tensor_set.add(var.alias_name) + else: + counter = 1 + for dim in self.feed_shapes_[var.alias_name]: + counter *= dim for i, var in enumerate(model_conf.fetch_var): self.fetch_types_[var.alias_name] = var.fetch_type if self.fetch_types_[var.alias_name] == 'float': @@ -435,6 +439,14 @@ class GClient(object): itype = self.type_map_[self.feed_types_[name]] data = np.array(var, dtype=itype) inst.data.append(data.tobytes()) + if isinstance(var, np.ndarray): + inst.shape.append( + np.array( + list(var.shape), dtype="int32").tobytes()) + else: + inst.shape.append( + np.array( + self.feed_shapes_[name], dtype="int32").tobytes()) req.feed_insts.append(inst) return req diff --git a/python/paddle_serving_server/__init__.py b/python/paddle_serving_server/__init__.py index c5c4734b3c2257aef556e7cb9fcc941f4bc9349b..56ddaf96742e6fe51a7d697bb8a5c993fbd029bb 100644 --- a/python/paddle_serving_server/__init__.py +++ b/python/paddle_serving_server/__init__.py @@ -481,8 +481,10 @@ class GServerService( feed_dict = {} for idx, name in enumerate(feed_inst.names): data = feed_inst.data[idx] + shape = feed_inst.shape[idx] itype = self.type_map_[self.feed_types_[name]] feed_dict[name] = np.frombuffer(data, dtype=itype) + feed_dict[name].shape = np.frombuffer(shape, dtype="int32") feed_batch.append(feed_dict) return feed_batch, fetch_names