Loading amsmath naturally switches \frac to \tfrac when in "inline math" (or text style) and \dfrac under "display math" (or display style). This provides a better layout:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
See $\frac{1}{2}$, or
\[
\frac{1}{2} \quad e^{\frac{1}{2}}.
\]
\end{document}
However, you can update \frac to condition based on the style using \mathchoice:

\documentclass{article}
\let\oldfrac\frac% Store \frac
\renewcommand{\frac}[2]{%
\mathchoice
{\oldfrac{#1}{#2}}% display style
{#1/#2}% text style
{#1/#2}% script style
{#1/#2}% script-script style
}
\begin{document}
See $\frac{1}{2}$, or
\[
\frac{1}{2} \quad e^{\frac{1}{2}}.
\]
\end{document}
Given that (say) \frac{x+y}{x-y} will be set as x+y/x-y when in text style, and technically have an incorrect mathematical representation, one could venture one step further. That is, measure the numerator and denominator width, and set it inside brackets if necessary:

\documentclass{article}
\let\oldfrac\frac% Store \frac
\makeatletter
\newcommand{\groupit}[1]{(#1)}% To group...
\newcommand{\nogroupit}[1]{#1}% ...or not to group
\renewcommand{\frac}[2]{%
\setbox\z@\hbox{$#1$}% Store numerator
\setbox\tw@\hbox{$#2$}% Store denominator
\ifdim\wd\z@>1em \let\groupornot@i\groupit\else\let\groupornot@i\nogroupit\fi% Measure numerator
\ifdim\wd\tw@>1em \let\groupornot@ii\groupit\else\let\groupornot@ii\nogroupit\fi% Measure denominator
\mathchoice
{\oldfrac{#1}{#2}}% display style
{\groupornot@i{#1}/\groupornot@ii{#2}}% text style
{\groupornot@i{#1}/\groupornot@ii{#2}}% script style
{\groupornot@i{#1}/\groupornot@ii{#2}}% script-script style
}
\makeatother
\begin{document}
See $\frac{1}{2}$ or $\frac{m}{x^2}$, or
\[
\frac{1}{2} \quad e^{\frac{1}{2}} \quad e^{\frac{x+y}{x-y}}.
\]
\end{document}
\newcommand\sfrac[2]{#1/#2}, then you keep the argument separation, and it is just one extra letter. Actually detecting inline math might be difficult. – daleif Jun 29 '16 at 22:40\ifinnerfor that), but rather the fact that the semantics might change when switching from one notation to the other: compare\frac{x+y}{x-y}with(x+y)/(x-y)and withx-y/x-y. Generally speaking, I wouldn’t recommend trusting an automatic substitution like this except in very simple cases. – GuM Jun 29 '16 at 23:17\ifinneris not a test for inline math, there are many items in display math that also end up with\ifinnerbeing true. – daleif Jun 30 '16 at 07:07\mathchoice, that is, on the current style, is much more reliable, at least for this kind of problem. – GuM Jun 30 '16 at 22:42