You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to suggest the support of torchscript for production use of nnAudio.
Currently, it does not work with the command script_model = torch.jit.script(model) with following errors.
---------------------------------------------------------------------------RuntimeErrorTraceback (mostrecentcalllast)
CellIn[6], line1---->1sm=torch.jit.script(model)
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_script.py:1324, inscript(obj, optimize, _frames_up, _rcb, example_inputs)
1322ifisinstance(obj, torch.nn.Module):
1323obj=call_prepare_scriptable_func(obj)
->1324returntorch.jit._recursive.create_script_module(
1325obj, torch.jit._recursive.infer_methods_to_compile1326 )
1327else:
1328obj=obj.__prepare_scriptable__() ifhasattr(obj, "__prepare_scriptable__") elseobj# type: ignore[operator]File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:559, increate_script_module(nn_module, stubs_fn, share_types, is_tracing)
557ifnotis_tracing:
558AttributeTypeIsSupportedChecker().check(nn_module)
-->559returncreate_script_module_impl(nn_module, concrete_type, stubs_fn)
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:632, increate_script_module_impl(nn_module, concrete_type, stubs_fn)
629script_module._concrete_type=concrete_type631# Actually create the ScriptModule, initializing it with the function we just defined-->632script_module=torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
634# Compile methods if necessary635ifconcrete_typenotinconcrete_type_store.methods_compiled:
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_script.py:639, inRecursiveScriptModule._construct(cpp_module, init_fn)
626""" 627 Construct a RecursiveScriptModule that's ready for use. PyTorch 628 code should use this to construct a RecursiveScriptModule instead (...) 636 init_fn: Lambda that initializes the RecursiveScriptModule passed to it. 637 """638script_module=RecursiveScriptModule(cpp_module)
-->639init_fn(script_module)
641# Finalize the ScriptModule: replace the nn.Module state with our642# custom implementations and flip the _initializing bit.643RecursiveScriptModule._finalize_scriptmodule(script_module)
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:608, increate_script_module_impl.<locals>.init_fn(script_module)
605scripted=orig_value606else:
607# always reuse the provided stubs_fn to infer the methods to compile-->608scripted=create_script_module_impl(
609orig_value, sub_concrete_type, stubs_fn610 )
612cpp_module.setattr(name, scripted)
613script_module._modules[name] =scriptedFile/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:632, increate_script_module_impl(nn_module, concrete_type, stubs_fn)
629script_module._concrete_type=concrete_type631# Actually create the ScriptModule, initializing it with the function we just defined-->632script_module=torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
634# Compile methods if necessary635ifconcrete_typenotinconcrete_type_store.methods_compiled:
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_script.py:639, inRecursiveScriptModule._construct(cpp_module, init_fn)
626""" 627 Construct a RecursiveScriptModule that's ready for use. PyTorch 628 code should use this to construct a RecursiveScriptModule instead (...) 636 init_fn: Lambda that initializes the RecursiveScriptModule passed to it. 637 """638script_module=RecursiveScriptModule(cpp_module)
-->639init_fn(script_module)
641# Finalize the ScriptModule: replace the nn.Module state with our642# custom implementations and flip the _initializing bit.643RecursiveScriptModule._finalize_scriptmodule(script_module)
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:608, increate_script_module_impl.<locals>.init_fn(script_module)
605scripted=orig_value606else:
607# always reuse the provided stubs_fn to infer the methods to compile-->608scripted=create_script_module_impl(
609orig_value, sub_concrete_type, stubs_fn610 )
612cpp_module.setattr(name, scripted)
613script_module._modules[name] =scripted
[... skippingsimilarframes: RecursiveScriptModule._constructatline639 (1times), create_script_module_implatline632 (1times), create_script_module_impl.<locals>.init_fnatline608 (1times)]
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:632, increate_script_module_impl(nn_module, concrete_type, stubs_fn)
629script_module._concrete_type=concrete_type631# Actually create the ScriptModule, initializing it with the function we just defined-->632script_module=torch.jit.RecursiveScriptModule._construct(cpp_module, init_fn)
634# Compile methods if necessary635ifconcrete_typenotinconcrete_type_store.methods_compiled:
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_script.py:639, inRecursiveScriptModule._construct(cpp_module, init_fn)
626""" 627 Construct a RecursiveScriptModule that's ready for use. PyTorch 628 code should use this to construct a RecursiveScriptModule instead (...) 636 init_fn: Lambda that initializes the RecursiveScriptModule passed to it. 637 """638script_module=RecursiveScriptModule(cpp_module)
-->639init_fn(script_module)
641# Finalize the ScriptModule: replace the nn.Module state with our642# custom implementations and flip the _initializing bit.643RecursiveScriptModule._finalize_scriptmodule(script_module)
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:608, increate_script_module_impl.<locals>.init_fn(script_module)
605scripted=orig_value606else:
607# always reuse the provided stubs_fn to infer the methods to compile-->608scripted=create_script_module_impl(
609orig_value, sub_concrete_type, stubs_fn610 )
612cpp_module.setattr(name, scripted)
613script_module._modules[name] =scriptedFile/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:636, increate_script_module_impl(nn_module, concrete_type, stubs_fn)
634# Compile methods if necessary635ifconcrete_typenotinconcrete_type_store.methods_compiled:
-->636create_methods_and_properties_from_stubs(
637concrete_type, method_stubs, property_stubs638 )
639# Create hooks after methods to ensure no name collisions between hooks and methods.640# If done before, hooks can overshadow methods that aren't exported.641create_hooks_from_stubs(concrete_type, hook_stubs, pre_hook_stubs)
File/mypath/.venv/lib/python3.11/site-packages/torch/jit/_recursive.py:469, increate_methods_and_properties_from_stubs(concrete_type, method_stubs, property_stubs)
466property_defs= [p.def_forpinproperty_stubs]
467property_rcbs= [p.resolution_callbackforpinproperty_stubs]
-->469concrete_type._create_methods_and_properties(
470property_defs, property_rcbs, method_defs, method_rcbs, method_defaults471 )
RuntimeError:
Triedtosetnonexistentattribute: num_samples. Didyouforgettoinitializeitin__init__()?:
File"/mypath/.venv/lib/python3.11/site-packages/nnAudio/features/stft.py", line275
"""output_format=output_formatorself.output_formatself.num_samples=x.shape[-1]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<---HEREx=broadcast_dim(x)
Thank you :)
The text was updated successfully, but these errors were encountered:
Hi, thank you for such an amazing project!
I want to suggest the support of torchscript for production use of nnAudio.
Currently, it does not work with the command
script_model = torch.jit.script(model)
with following errors.Thank you :)
The text was updated successfully, but these errors were encountered: