MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _replace_scale_node

Function _replace_scale_node

tensorflow/tools/compatibility/tf_upgrade_v2.py:2370–2383  ·  view source on GitHub ↗

Replaces old_value with 0.5*(old_value).

(parent, old_value)

Source from the content-addressed store, hash-verified

2368 Also drops the scope argument.
2369 """
2370 def _replace_scale_node(parent, old_value):
2371 """Replaces old_value with 0.5*(old_value)."""
2372 half = ast.Num(n=0.5)
2373 half.lineno = 0
2374 half.col_offset = 0
2375 new_value = ast.BinOp(left=half, op=ast.Mult(),
2376 right=old_value)
2377 # This copies the prefix and suffix on old_value to new_value.
2378 pasta.ast_utils.replace_child(parent, old_value, new_value)
2379
2380 # Put parentheses around scale.value (and remove the old prefix/
2381 # suffix, they should only be around new_value).
2382 pasta.base.formatting.set(old_value, "prefix", "(")
2383 pasta.base.formatting.set(old_value, "suffix", ")")
2384
2385 # Check if we have a scale or scope keyword arg
2386 scope_keyword = None

Calls 1

setMethod · 0.45

Tested by

no test coverage detected