MCPcopy Create free account
hub / github.com/apple/axlearn / get_invocation_context

Method get_invocation_context

axlearn/common/module.py:1084–1096  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1082 if part not in target_state:
1083 raise InvalidDescendantError(
1084 f"Module '{target_module.path()}' state does not contain '{part}' from path "
1085 f"'{'.'.join(path_from_ancestor)}'. The state contains: {target_state.keys()}"
1086 )
1087 target_module, target_state = target_module.children[part], target_state[part]
1088
1089 return Module.SharedModuleInfo(
1090 module=target_module, state=target_state, name=shared_module_or_name
1091 )
1092
1093 def get_invocation_context(self) -> InvocationContext: # pytype: disable=invalid-annotation
1094 context = current_context()
1095 if not context:
1096 raise RuntimeError(
1097 "Module invocation context not found. "
1098 "Did you invoke the module inside functional(...)?"
1099 )

Callers 15

get_shared_moduleMethod · 0.95
is_trainingMethod · 0.95
prng_keyMethod · 0.95
stateMethod · 0.95
add_summaryMethod · 0.95
add_state_updateMethod · 0.95
add_module_outputMethod · 0.95
get_module_outputsMethod · 0.95
transform_updateMethod · 0.80
transform_updateMethod · 0.80
forwardMethod · 0.80
_metricsMethod · 0.80

Calls 1

current_contextFunction · 0.85

Tested by

no test coverage detected