Git Product home page Git Product logo

Comments (8)

ToucheSir avatar ToucheSir commented on May 6, 2024

A quick question about this: what would non-alphanumeric characters be replaced with? Considering what characters https://github.com/tensorflow/tensorflow/blob/v1.8.0/tensorflow/core/graph/graph_constructor.cc#L57 accepts, should emoji, etc. be removed entirely or converted to some ascii-friendly alphanumeric equivalent during name mangling?

from swift.

dan-zheng avatar dan-zheng commented on May 6, 2024

Removal is certainly the simplest solution.
The regex for allowable names is quite restrictive (from here): "[A-Za-z0-9.][A-Za-z0-9_./]*".
I don't know of any standard string escaping conventions that map onto just alphanumeric characters.

Does anyone have a better alternative to removing invalid characters?

from swift.

dan-zheng avatar dan-zheng commented on May 6, 2024

I'm taking this on because it blocks #8.

The compiler-integrated REPL has the filename <REPL Input>, which is invalid.

$ build/buildbot_linux/swift-linux-x86_64/bin/swift
***  You are running Swift's integrated REPL,  ***
***  intended for compiler and stdlib          ***
***  development and testing purposes only.    ***
***  The full REPL is built as part of LLDB.   ***
***  Type ':help' for assistance.              ***
(swift) import TensorFlow
(swift) let x = Tensor(1)
2018-05-01 21:34:33.631820: E tensorflow/core/common_runtime/executor.cc:660] Executor failed to create kernel. Invalid argument: Node 'op.<REPL Input>.1.16': Node name contains invalid characters
	 [[Node: tfc_func_main.tf_partition = main.tf_partition[_device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Fatal error: Node 'op.<REPL Input>.1.16': Node name contains invalid characters

from swift.

ToucheSir avatar ToucheSir commented on May 6, 2024

The only thing I could think of was (for emoji specifically) using the codepoint number (e.g. 🐦 becomes U1F426). On second thought, though, that doesn't seem like it'd provide a lot of value over just removing the character.

On an unrelated note, it's great to be able to see and follow the development of this. Looking forward to trying out all of the wonderful new features!

from swift.

rxwei avatar rxwei commented on May 6, 2024

@dan-zheng To unblock compiler integrated REPL, the shortest path we can take is to replace spaces with underscores. This issue should be left open. Thanks!

from swift.

dan-zheng avatar dan-zheng commented on May 6, 2024

An alternative to removing invalid characters is to replace them with _. That may look nicer for some filenames, but falls apart for Unicode characters.

  • <REPL Input>
    • Removal: REPLInput
    • Underscore: _REPL_Input_
  • Swift for TensorFlow.playground
    • Removal: SwiftforTensorFlow.playground
    • Underscore: Swift_for_TensorFlow.playground
  • 😃🐦😎asdf
    • Removal: asdf
    • Underscore: ____________asdf

I'll go ahead and use underscores for now to unblock #8, but I'll leave this issue open.
A robust escaping mechanism should handle unicode characters (using llvm::UTF8 or some other means) and be reversible.

from swift.

dan-zheng avatar dan-zheng commented on May 6, 2024

Replaced invalid characters with underscores in 5233a8f.

from swift.

rxwei avatar rxwei commented on May 6, 2024

@dan-zheng Could you cherry-pick and move this one to JIRA too?

from swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.