Skip to content

Commit

Permalink
Add logging around callable workaround.
Browse files Browse the repository at this point in the history
Let's know whent his occurs.
  • Loading branch information
khatchad committed Jan 10, 2024
1 parent 05c0f41 commit be73ebf
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ public IMethod getCalleeTarget(CGNode caller, CallSiteReference site, IClass rec
PythonInvokeInstruction call = (PythonInvokeInstruction) caller.getIR().getCalls(site)[0];

if (callable) {
logger.fine("Encountered callable.");

// It's a callable. Change the receiver.
receiver = getCallable(caller, cha, call);

if (receiver == null) return null; // not found.
else logger.fine("Substituting the receiver with one derived from a callable.");
}

Pair<IClass, Integer> key = Pair.make(receiver, call.getNumberOfTotalParameters());
Expand Down Expand Up @@ -202,14 +205,20 @@ private IClass getCallable(CGNode caller, IClassHierarchy cha, PythonInvokeInstr
classLoaderReference, packageName, CALLABLE_METHOD_NAME));

// TODO: Remove this code once https://github.com/wala/ML/issues/118 is completed.
if (callable == null)
if (callable == null) {
// try the workaround for https://github.com/wala/ML/issues/106. NOTE: We cannot verify that
// the super class is tf.keras.Model due to https://github.com/wala/ML/issues/118.
logger.fine("Attempting callable workaround for https://github.com/wala/ML/issues/118.");

callable =
cha.lookupClass(
TypeReference.findOrCreateClass(
classLoaderReference, packageName, CALLABLE_METHOD_NAME_FOR_KERAS_MODELS));

if (callable != null)
logger.info("Applying callable workaround for https://github.com/wala/ML/issues/118.");
}

if (callable != null) return callable;
}

Expand Down

0 comments on commit be73ebf

Please sign in to comment.