aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/local_service.cc
diff options
context:
space:
mode:
authorGravatar Chris Leary <leary@google.com>2018-01-17 16:54:30 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-01-17 16:57:42 -0800
commitc2f1e2d8dba2fc568ab4c4eb42b0ae24a0c0b02b (patch)
treee694b225f23100cef1a9ccaeb404154cf0bd13fe /tensorflow/compiler/xla/service/local_service.cc
parent0304b6630f3fcda6602d24e91ab3dd31e46f495f (diff)
[XLA] Add source mapping support to SWIG API.
PiperOrigin-RevId: 182292142
Diffstat (limited to 'tensorflow/compiler/xla/service/local_service.cc')
-rw-r--r--tensorflow/compiler/xla/service/local_service.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/tensorflow/compiler/xla/service/local_service.cc b/tensorflow/compiler/xla/service/local_service.cc
index d5715aa27b..2194d24257 100644
--- a/tensorflow/compiler/xla/service/local_service.cc
+++ b/tensorflow/compiler/xla/service/local_service.cc
@@ -84,15 +84,30 @@ StatusOr<std::unique_ptr<Executable>> LocalService::CompileExecutable(
// Validate incoming layouts.
if (argument_layouts.size() != program_shape->parameters_size()) {
return InvalidArgument(
- "invalid number of arguments for computation: expected %d, got %zu",
+ "Invalid number of arguments for computation: expected %d, got %zu.",
program_shape->parameters_size(), argument_layouts.size());
}
for (int i = 0; i < argument_layouts.size(); ++i) {
const Shape& argument_shape = *argument_layouts[i];
TF_RETURN_IF_ERROR(ShapeUtil::ValidateShape(argument_shape));
if (!ShapeUtil::Compatible(argument_shape, program_shape->parameters(i))) {
+ tensorflow::gtl::optional<const OpMetadata*> metadata =
+ user_computation->ParameterMetadata(i);
+ auto metadata_string = [&metadata]() -> string {
+ if (!metadata.has_value()) {
+ return "";
+ }
+ CHECK(metadata.value() != nullptr);
+ const OpMetadata& m = *metadata.value();
+ if (!m.source_file().empty()) {
+ return tensorflow::strings::Printf(
+ " (%s:%d)", m.source_file().c_str(), m.source_line());
+ }
+ return "";
+ };
return InvalidArgument(
- "invalid argument shape for argument %d, expected %s, got %s", i,
+ "Invalid argument shape for argument %d%s, expected %s, got %s.", i,
+ metadata_string().c_str(),
ShapeUtil::HumanString(program_shape->parameters(i)).c_str(),
ShapeUtil::HumanString(argument_shape).c_str());
}