Fix a check in tfcompile codegen.
Previously, tfcompile expects the compiler to translate each resource variable into a function argument. The MLIR bridge doesn't generated a function argument for an unused resource variable. Modify an existing test to test the situation. PiperOrigin-RevId: 302083482 Change-Id: I08301e594422f655b8d4ba4bb66d69103764cc7f
This commit is contained in:
parent
9df9b1a1f3
commit
38ca061ed3
@ -170,7 +170,9 @@ Status GenArgMethods(const tf2xla::Config& config,
|
||||
const xla::ProgramShapeProto& ps,
|
||||
const CompileResult& compile_result, string* methods) {
|
||||
size_t num_args = ps.parameters_size();
|
||||
if (config.feed_size() + config.variable_size() != num_args) {
|
||||
// feed_size() + variable_size() is the maximum number of args as an
|
||||
// implementation may not create an argument for an unused variable.
|
||||
if (config.feed_size() + config.variable_size() < num_args) {
|
||||
return errors::InvalidArgument(
|
||||
"mismatch between feed_size(", config.feed_size(), ")+variable_size(",
|
||||
config.variable_size(), ") and num_args(", num_args, ")");
|
||||
|
@ -157,6 +157,7 @@ def tftop_k(_):
|
||||
|
||||
def tfvariable_readonly(_):
|
||||
x = variables.Variable(1000.0, name='x')
|
||||
unused_y = variables.Variable(1000.0, name='y')
|
||||
old_x = x.value()
|
||||
with ops.control_dependencies([old_x]):
|
||||
new_value = math_ops.add(old_x, 42.0)
|
||||
|
@ -10,3 +10,11 @@ variable {
|
||||
type: DT_FLOAT
|
||||
readonly: true
|
||||
}
|
||||
|
||||
variable {
|
||||
node_name: "y"
|
||||
shape {
|
||||
}
|
||||
type: DT_FLOAT
|
||||
readonly: true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user