Spenso · latest
On this page

TensorEvaluator

symbolica.community.tensor Class

TensorEvaluator()

Symbolica evaluator returning component tensors in their original logical layout.

Construct with Tensor.evaluator. The scalar_evaluator property exposes the underlying Symbolica Evaluator for precision evaluation, export and inspection.

Member details

parameters

Property · read-only#
parameters: list[Expression]

Symbolic inputs in evaluation order.

input_size

Property · read-only#
input_size: int

Number of entries in an input row.

output_shape

Property · read-only#
output_shape: tuple[int, ...]

Logical shape of each output tensor, excluding the batch dimension.

supports_real

Property · read-only#
supports_real: bool

Whether all exact coefficients are real.

scalar_evaluator

Property · read-only#
scalar_evaluator: Evaluator

Underlying Symbolica Evaluator, with outputs in logical component order.

Use for arbitrary-precision evaluation, export, or instruction inspection. These operations return scalar components; they do not wrap tensor metadata.

__repr__

Method#
__repr__() -> str

Describe the output tensor layout and supported numeric domains.

evaluate

Method#
evaluate(inputs: numpy.ArrayLike) -> list[Tensor]

Evaluate real inputs using Symbolica's ArrayLike input conventions.

Returns one Tensor per row. A flat input array is also accepted, with the same reshaping and validation as Evaluator.evaluate.

Parameters

NameTypeDefaultDescription
inputsnumpy.ArrayLike——

evaluate_complex

Method#
evaluate_complex(inputs: numpy.ArrayLike) -> list[Tensor]

Evaluate complex inputs; returns one Tensor per input row.

Parameters

NameTypeDefaultDescription
inputsnumpy.ArrayLike——

jit_compile

Method#
jit_compile(jit_compile: bool, direct_translation: Optional[bool] = None, optimization_level: Optional[int] = None, options: Optional[Mapping[str, str]] = None) -> None

Enable or disable JIT compilation with Symbolica's settings.

Parameters

NameTypeDefaultDescription
jit_compilebool——
direct_translationOptional[bool]None—
optimization_levelOptional[int]None—
optionsOptional[Mapping[str, str]]None—

set_real_params

Method#
set_real_params(real_params: Sequence[int], sqrt_real: bool = False, log_real: bool = False, powf_real: bool = False, real_if_args_real: bool = False, verbose: bool = False) -> None

Mark real parameters using the same assumptions as Evaluator.set_real_params.

Parameters

NameTypeDefaultDescription
real_paramsSequence[int]——
sqrt_realboolFalse—
log_realboolFalse—
powf_realboolFalse—
real_if_args_realboolFalse—
verboseboolFalse—

compile

Method#
compile(function_name: str, filename: str, library_name: str, number_type: str, inline_asm: str = 'default', optimization_level: int = 3, native: bool = True, compiler_path: Optional[str] = None, compiler_flags: Optional[Sequence[str]] = None, custom_header: Optional[str] = None, cuda_number_of_evaluations: int = 1, cuda_block_size: int = 512) -> CompiledTensorEvaluator

Compile a native evaluator with the same options as Evaluator.compile.

number_type selects real, complex, real_4x, complex_4x, cuda_real or cuda_complex. The returned object's evaluate method uses that number type and returns tensors. Source and library files are written to the given paths.

Parameters

NameTypeDefaultDescription
function_namestr——
filenamestr——
library_namestr——
number_typestr——
inline_asmstr'default'—
optimization_levelint3—
nativeboolTrue—
compiler_pathOptional[str]None—
compiler_flagsOptional[Sequence[str]]None—
custom_headerOptional[str]None—
cuda_number_of_evaluationsint1—
cuda_block_sizeint512—