SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2003.09040 · 2020

TF-Coder: Program Synthesis for Tensor Manipulations

arXiv · PDF · Open in the Atlas

Code that ran

8 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 8 have no contract verdict; 0 failures of our instrument; 6 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2003.09040.json · badge: /api/ran/2003.09040.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
google-research/tensorflow-coder canonical (classifier label)
classifier basis: census
7 ran · 1 no recorded run
grwlf/galaxy-lang community (classifier label)
classifier basis not recorded on the link
1 ran · 5 no recorded run
FunctionStatusWhere it lives
convert_to_tensor Ran
ran on a synthesized input
google-research/tensorflow-coder/tf_coder/tf_coder_utils.py
code served (permissive licence) · get_code("3f4d2d582062c028")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned EagerTensor, ndim 2, dtype family int, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tensorflow as tf

# Create various tensor-like objects to test the function

# Test case 1: Regular Python list (n-dimensional)
list_tensor = [[1, 2, 3], [4, 5, 6]]

# Test case 2: tf.Tensor
tensor_object = tf.constant([[7, 8, 9], [10, 11, 12]], dtype=tf.float32)

# Test case 3: tf.SparseTensor
indices = tf.constant([[0, 0], [1, 2]], dtype=tf.int64)
values = tf.constant([1.0, 2.0], dtype=tf.float32)
shape = tf.constant([2, 3], dtype=tf.int64)
sparse_tensor = tf.SparseTensor(indices=indices, values=values, dense_shape=shape)

# Test case 4: Scalar
scalar = 42

ARGS = {
    "tensor_like": list_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family int, shape (2, 3) — shape (2, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_tf_function Ran
ran on a synthesized input
google-research/tensorflow-coder/tf_coder/tf_coder_utils.py
code served (permissive licence) · get_code("5bb98767d8fda208")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import operator
import tensorflow as tf

def get_tf_function(function_name):
    """Returns a TensorFlow function object given its name.

  Args:
    function_name: The string name of the function, e.g., "tf.matmul". Must
      start with "tf.". Nested modules are allowed, e.g., "tf.nn.softmax".

  Returns:
    The function object corresponding to function_name.

  Raises:
    ValueError: If the function name does not start with "tf.", or the function
      could not be found.
  """
    TF_PREFIX = 'tf.'
    if not function_name.startswith(TF_PREFIX):
        raise ValueError('get_tf_function() called with function {}, which does not start with "tf.".'.format(function_name))
    function_name_without_prefix = function_name[len(TF_PREFIX):]
    try:
        tf_function = operator.attrgetter(function_name_without_prefix)(tf)
        if tf_function is None:
            raise ValueError('Could not find TF function {}'.format(function_name))
        return tf_function
    except AttributeError:
        raise ValueError('AttributeError encountered in get_tf_function for name {}'.format(function_name))

ARGS = {
    'function_name': 'tf.matmul'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ignore Ran
ran on a synthesized input
google-research/tensorflow-coder/tf_coder/benchmarks/benchmark.py
code served (permissive licence) · get_code("438f09dc53707971")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

# Define a simple benchmark class that the decorator will modify
class SimpleBenchmark:
    def __init__(self):
        self.should_ignore = False
        self.ignore_reason = None

# Define a simple benchmark-creating function to decorate
def create_benchmark():
    return SimpleBenchmark()

# The ignore decorator takes a single parameter: ignore_reason
ARGS = {
    "ignore_reason": "This benchmark is skipped due to known limitation"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
num_tensor_elements Ran
ran on a synthesized input
google-research/tensorflow-coder/tf_coder/tf_coder_utils.py
code served (permissive licence) · get_code("2a387f7c2d6d3940")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tensorflow as tf

def num_tensor_elements(tensor):
    """Returns the number of elements in a tensor as an int (primitive)."""
    return int(tf.size(tensor))

# Create a small TensorFlow tensor
tensor = tf.constant([[1, 2, 3, 4], [5, 6, 7, 8]])

ARGS = {
    "tensor": tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int — no output shape is stated: observe_signature.py could not observe it (call:TypeError)
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse Ran
ran on a synthesized input
google-research/tensorflow-coder/tf_coder_colab_logging/serialization.py
code served (permissive licence) · get_code("96d83889ae3ee17c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned EagerTensor, ndim 1, dtype family int, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tensorflow as tf
import ast

# Create a serialized representation that can be parsed
# The parse function takes a serialized string and converts it back to objects

# Example 1: Simple dtype
serialized_dtype = "{'kind': 'DType', 'dtype': 'float32'}"

# Example 2: Tensor
serialized_tensor = "{'kind': 'Tensor', 'content': [1, 2, 3, 4], 'dtype': {'kind': 'DType', 'dtype': 'int32'}}"

# Example 3: SparseTensor
serialized_sparse = "{'kind': 'SparseTensor', 'indices': {'kind': 'Tensor', 'content': [[0, 0], [1, 2]], 'dtype': {'kind': 'DType', 'dtype': 'int64'}}, 'values': {'kind': 'Tensor', 'content': [1, 2], 'dtype': {'kind': 'DType', 'dtype': 'float32'}}, 'dense_shape': {'kind': 'Tensor', 'content': [3, 4], 'dtype': {'kind': 'DType', 'dtype': 'int64'}}}"

# Example 4: Dict
serialized_dict = "{'kind': 'Dict', 'dict': {'a': 1, 'b': 2.5}}"

# Example 5: List of primitives
serialized_list = "[1, 2, 3, 'hello', True, None]"

# Example 6: Nested structure
serialized_nested = "{'kind': 'Dict', 'dict': {'tensor': {'kind': 'Tensor', 'content': [1.0, 2.0], 'dtype': {'kind': 'DType', 'dtype': 'float32'}}, 'value': 42}}"

ARGS = {
    'serialized': serialized_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 1, dtype family int, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
parse_function_info_name Ran
ran on a synthesized input
google-research/tensorflow-coder/tf_coder/tf_functions.py
code served (permissive licence) · get_code("c1fbb742c7172e0f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import collections

class FunctionInfo:
    """Stand-in class for FunctionInfo namedtuple."""
    def __init__(self, name):
        self.name = name

ARGS = {
    'function_info': FunctionInfo('tf.foo.bar(x, axis, baz=True)')
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
permute Ran
ran on a synthesized input
grwlf/galaxy-lang/src/galang/gen.py
code served (permissive licence) · get_code("40fe88a021d3c23b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
from typing import List, Dict, Optional, Iterable, Tuple, Set, Iterator, Callable

torch.manual_seed(0)

ARGS = {
    "weights": [1, 2, 3],
    "nargs": 2,
    "target_weight": 3
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
serialize Ran
ran on a synthesized input
google-research/tensorflow-coder/tf_coder_colab_logging/serialization.py
code served (permissive licence) · get_code("6363dbc5c6d4760f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tensorflow as tf
import numpy as np

# Test with various serializable objects
ARGS = {
    'to_serialize': {
        'tensor': tf.constant([1, 2, 3], dtype=tf.int32),
        'dtype': tf.float32,
        'sparse': tf.SparseTensor(
            indices=[[0, 0], [1, 1]],
            values=[1.0, 2.0],
            dense_shape=[2, 2]
        ),
        'nested_dict': {
            'int_val': 42,
            'float_val': 3.14,
            'bool_val': True,
            'str_val': 'hello',
            'bytes_val': b'world',
            'none_val': None,
            'list': [1, 2, 3],
            'tuple': (4, 5, 6),
            'set': {7, 8, 9}
        }
    }
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_model Not yet run
unverified (harvested, no recorded run)
google-research/tensorflow-coder/tf_coder/models/tensor_features_model.py
code served (permissive licence) · get_code("e5a418212e1a1f5b")
How it ran

no invocation recorded.

isref Not yet run
unverified (harvested, no recorded run)
grwlf/galaxy-lang/graveyard/src/galang/lang.py
code served (permissive licence) · get_code("2c63d1e3ef45d825")
How it ran

no invocation recorded.

isterm Not yet run
unverified (harvested, no recorded run)
grwlf/galaxy-lang/graveyard/src/galang/lang.py
code served (permissive licence) · get_code("a96993f78c769fb4")
How it ran

no invocation recorded.

mkname Not yet run
unverified (harvested, no recorded run)
grwlf/galaxy-lang/src/galang/edsl.py
code served (permissive licence) · get_code("71458c45ce0b2969")
How it ran

no invocation recorded.

mkterm Not yet run
unverified (harvested, no recorded run)
grwlf/galaxy-lang/graveyard/src/galang/lang.py
code served (permissive licence) · get_code("b92eabdc465292f2")
How it ran

no invocation recorded.

mkterm Not yet run
unverified (harvested, no recorded run)
grwlf/galaxy-lang/graveyard/src/solution/lang.py
code served (permissive licence) · get_code("d63ee67ff03ddb40")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 13 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The success and popularity of deep learning is on the rise, partially due to powerful deep learning frameworks such as TensorFlow and PyTorch that make it easier to develop deep learning models. However, these libraries also come with steep learning curves, since programming in these frameworks is quite different from traditional imperative programming with explicit loops and conditionals. In this work, we present a tool called TF-Coder for programming by example in TensorFlow. TF-Coder uses a bottom-up weighted enumerative search, with value-based pruning of equivalent expressions and flexible type- and value-based filtering to ensure that expressions adhere to various requirements imposed by the TensorFlow library. We train models to predict TensorFlow operations from features of the input and output tensors and natural language descriptions of tasks, to prioritize relevant operations during search. TF-Coder solves 63 of 70 real-world tasks within 5 minutes, sometimes finding simpler solutions in less time compared to experienced human programmers.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2003.09040")
get_code_for_paper("2003.09040")
have("2003.09040")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2003.09040.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2003.09040.svg)](https://syntology.ai/paper/2003.09040)

Connect an agent — have() is free.