diff --git a/aten/src/ATen/core/interned_strings.h b/aten/src/ATen/core/interned_strings.h index a7e1e8be710..3c35659440b 100644 --- a/aten/src/ATen/core/interned_strings.h +++ b/aten/src/ATen/core/interned_strings.h @@ -43,7 +43,6 @@ namespace c10 { _(prim, Store) \ _(prim, Undefined) \ _(prim, Starred) \ - _(prim, ToString) \ _(prim, TupleConstruct) \ _(prim, TupleUnpack) \ _(prim, TupleIndex) \ diff --git a/test/expect/TestScript.test_str_cast-stdout.expect b/test/expect/TestScript.test_str_cast-stdout.expect deleted file mode 100644 index 1c9e1f422ae..00000000000 --- a/test/expect/TestScript.test_str_cast-stdout.expect +++ /dev/null @@ -1,5 +0,0 @@ -0 -[ Variable[CPULongType]{} ] -2 -1 -2.5 diff --git a/test/expect/TestScript.test_str_cast.expect b/test/expect/TestScript.test_str_cast.expect deleted file mode 100644 index e0bcb45ee7f..00000000000 --- a/test/expect/TestScript.test_str_cast.expect +++ /dev/null @@ -1,14 +0,0 @@ -graph(%a : Dynamic - %b : int - %c : bool - %d : float) { - %4 : string = prim::ToString(%a) - = prim::Print(%4) - %5 : string = prim::ToString(%b) - = prim::Print(%5) - %6 : string = prim::ToString(%c) - = prim::Print(%6) - %7 : string = prim::ToString(%d) - = prim::Print(%7) - return (%a); -} diff --git a/test/test_jit.py b/test/test_jit.py index fd31f89e838..a673d01ee00 100644 --- a/test/test_jit.py +++ b/test/test_jit.py @@ -8071,18 +8071,6 @@ a") return e self.checkScript(foo, (torch.rand(3), torch.rand(3))) - def test_str_cast(self): - def foo(a, b, c, d): - # type: (Tensor, int, bool, float) -> Tensor - print(str(a)) - print(str(b)) - print(str(c)) - print(str(d)) - return a - - self.checkScript(foo, (torch.tensor(0), 2, True, 2.5), capture_output=True) - self.assertExpectedGraph(torch.jit.script(foo).graph) - class MnistNet(nn.Module): def __init__(self): diff --git a/torch/csrc/jit/ir.cpp b/torch/csrc/jit/ir.cpp index 4c77c1b7a1a..ade978d3c3f 100644 --- a/torch/csrc/jit/ir.cpp +++ b/torch/csrc/jit/ir.cpp @@ -1302,12 +1302,6 @@ Node* Graph::createStringToFloat(Value* value) { return result; } -Node* Graph::createToString(Value* value) { - auto* result = create(prim::ToString, {value}); - result->output()->setType(StringType::get()); - return result; -} - Node* Graph::createClone(Node * n, std::function value_map, bool copy_blocks) { //n can be from a different graph Node * r = n->allocNewInstance(this); diff --git a/torch/csrc/jit/ir.h b/torch/csrc/jit/ir.h index a91cde7994e..3c1309838cb 100644 --- a/torch/csrc/jit/ir.h +++ b/torch/csrc/jit/ir.h @@ -846,8 +846,6 @@ public: TORCH_API Node* createIntToFloat(Value* value); TORCH_API Node* createFloatToInt(Value* value); TORCH_API Node* createStringToFloat(Value* value); - TORCH_API Node* createToString(Value* value); - Node* createPythonOp( THPObjectPtr&& pyobj, const std::string& cconv, diff --git a/torch/csrc/jit/register_prim_ops.cpp b/torch/csrc/jit/register_prim_ops.cpp index 5bf3756bf01..c12c989867a 100644 --- a/torch/csrc/jit/register_prim_ops.cpp +++ b/torch/csrc/jit/register_prim_ops.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -185,16 +184,6 @@ RegisterOperators reg({ return 0; }; }), - Operator( - prim::ToString, - [](Node* node) -> Operation { - return [](Stack& stack) { - std::stringstream ss; - ss << pop(stack); - push(stack, ss.str()); - return 0; - }; - }), Operator( prim::TensorDevice, [](const Node* node) -> Operation { diff --git a/torch/csrc/jit/script/compiler.cpp b/torch/csrc/jit/script/compiler.cpp index 840ab1ea02c..87267acf652 100644 --- a/torch/csrc/jit/script/compiler.cpp +++ b/torch/csrc/jit/script/compiler.cpp @@ -83,8 +83,6 @@ static Value* typeCast(const SourceRange& loc, Value* value, TypePtr dst) { n = graph.createIntToFloat(value); } else if(dst->isSubtypeOf(FloatType::get()) && orig->isSubtypeOf(StringType::get())) { n = graph.createStringToFloat(value); - } else if (dst->isSubtypeOf(StringType::get())) { - n = graph.createToString(value); } else { throw ErrorReport(loc) << "Cannot cast type '" << orig->str() << "' to type '" << dst->str() << "'."; @@ -326,7 +324,6 @@ struct Environment { {"float", std::make_shared(FloatType::get())}, {"int", std::make_shared(IntType::get())}, {"bool", std::make_shared(BoolType::get())}, - {"str", std::make_shared(StringType::get())}, // todo(zach): remove when we can correctly export torch.full via ONNX // or we have implicit conversion that can convert numbers to tensors {"_to_tensor", std::make_shared(DynamicType::get()) },